I have many files in a Folder in want to include in a Template (EJS).
I try this:
<% var test = ["foo.ejs"];
_forEach(test, function(item){ %>
<% include slides/item %>
<% }); %>
I would use Nodejs to fill the Array by looking in a folder.
But i get the error:
Error: ENOENT, no such file or directory 'app/views/slides/item.ejs'
It seems that ejs dont use "item" as a variable.
Looks like this is now supported in EJS . It was introduced in v2.0.1: 2015-01-02. The new syntax looks like this
<%- include(yourVariable) %>
There is an issue for that problem in github. https://github.com/visionmedia/ejs/issues/93
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.