【问题标题】:EJS Template: Using forEach + includeEJS 模板:使用 forEach + include
【发布时间】: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”作为变量。

【问题讨论】:

标签: node.js ejs


【解决方案1】:

现在EJS 似乎支持此功能。它是在 v2.0.1: 2015-01-02 中引入的。新语法如下所示

【讨论】:

    【解决方案2】:

    在 github 中有一个针对该问题的问题。 https://github.com/visionmedia/ejs/issues/93

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-24
      • 1970-01-01
      • 1970-01-01
      • 2014-10-25
      • 2017-12-05
      • 2012-05-08
      • 1970-01-01
      • 2014-09-08
      相关资源
      最近更新 更多