node.js ejs include功能在我的情况下不起作用

发布于 2025-01-28 21:15:09 字数 893 浏览 2 评论 0原文

我想将header.ejs和footer.ejs包括在order.ejs中。 我的文件夹结构下方的图像。

但是,我有错误。与inder.ejs相关的代码在下面编写。

/// order.ejs

<%- include('../common/header.ejs') %>

我认为我的代码错了。但是我找不到任何解决方案。

提前致谢。

添加错误消息

Error: ejs:18
    16|                         <tr>
    17|                             <td align="center" valign="top">
 >> 18|                                 <%- include('../common/header.ejs') %>
    19|                             </td>
    20|                         </tr>
    21|                         <tr>

Could not find the include file "../common/header.ejs" {"timestamp":"2022-05-14 13:58:57"}

I want to include header.ejs and footer.ejs into order.ejs.
The image below my folder structure.

enter image description here

But, I've got error. The code related to include in order.ejs is written below.

/// order.ejs

<%- include('../common/header.ejs') %>

I think my code is wrong. But I could not find any solution.

Thanks in advance.

Add Error Message

Error: ejs:18
    16|                         <tr>
    17|                             <td align="center" valign="top">
 >> 18|                                 <%- include('../common/header.ejs') %>
    19|                             </td>
    20|                         </tr>
    21|                         <tr>

Could not find the include file "../common/header.ejs" {"timestamp":"2022-05-14 13:58:57"}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

述情 2025-02-04 21:15:09

我解决了这个问题。
问题不是模板,而是EJS功能。

旧功能:

ejs.compile()

新功能:

ejs.renderFile()

I have solved this issue.
The problem was not a template, but the EJS function.

OLD Function:

ejs.compile()

NEW Function:

ejs.renderFile()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文