ejs-“意外标识符”;使用include in for循环时 [英] ejs - "Unexpected identifier" when using include in for loop

查看:64
本文介绍了ejs-“意外标识符”;使用include in for循环时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用<%include components / aside.ejs%> <%include components / head.ejs%> ; 在我的代码中没有任何问题。但是当我在这样的for循环中使用 include

I'm using <% include components/aside.ejs %> or <% include components/head.ejs %> somewhere in my code without any problem. But when I use include in a for loop like this

<%
for (var i = 0; i < 20; i++) {
    include components/head.ejs;
}
%>

,在编译ejs时,我在[文件路径]中得到意外标识符

, I get Unexpected identifier in [file path] while compiling ejs.

是否有明显的错误我没有注意到?

Is there any obvious mistake that I'm not noticing?

推荐答案

为解决重大变化,从EJS 3.x开始,include的语法已从<%-include components / head.ejs%> <%-include('components / head.ejs'); %>

To fix a breaking change, as of EJS 3.x, the syntax for an include has gone from <%- include components/head.ejs %> to <%- include('components/head.ejs'); %>.

这篇关于ejs-“意外标识符”;使用include in for循环时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆