【发布时间】:2014-07-25 08:30:46
【问题描述】:
我的文件夹中有许多文件想要包含在模板 (EJS) 中。
我试试这个:
<% var test = ["foo.ejs"];
_forEach(test, function(item){ %>
<% include slides/item %>
<% }); %>
我会使用 Nodejs 通过查看文件夹来填充数组。
但我得到了错误:
Error: ENOENT, no such file or directory 'app/views/slides/item.ejs'
好像ejs不使用“item”作为变量。
【问题讨论】:
-
我认为你做不到。从 ejs code 读取,'include' 之后的任何内容都被视为文件模板位置