简体   繁体   English

意外的“/”<filepath> 编译ejs时

[英]Unexpected "/" in <filepath> while compiling ejs

I've set up an EJS partial under a path views/partials/ejspartial.ejs which I am trying to access in an ejs file with the path views/ejsfile.ejs .我已经在路径views/partials/ejspartial.ejs下设置了一个 EJS 部分,我试图在路径views/ejsfile.ejs的 ejs 文件中访问views/ejsfile.ejs This is the same views directory.这是相同的视图目录。

In the ejsfile.ejs , I've added the following line of code: <% include ./partials/ejspartial %>ejsfile.ejs ,我添加了以下代码行: <% include ./partials/ejspartial %>

When I load the ejsfile page, I get the following error:当我加载 ejsfile 页面时,出现以下错误:

SyntaxError: Unexpected token '/' in <path>/views/ejsfile while compiling ejs

I've tried swapping in the <%- tag and removing the ./ from the include statement, but the same error occurs.我尝试在<%-标记中交换并从include语句中删除./ ,但发生了同样的错误。

I suspect it is because you are using the syntax of an older version of EJS.我怀疑这是因为您使用的是旧版 EJS 的语法。

I notice that the docs say: "NOTE: Include preprocessor directives ( <% include user/show %> ) are still supported."我注意到文档说:“注意:仍然支持包含预处理器指令( <% include user/show %> )。”

However, the owner of the EJS repository says otherwise here: https://github.com/tj/ejs/issues/220但是,EJS 存储库的所有者在这里另有说明: https : //github.com/tj/ejs/issues/220

I would try the new syntax, <%- include('partials/ejspartial') %> , and see if that solves the issue.我会尝试新语法<%- include('partials/ejspartial') %> ,看看是否能解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM