Closed robogeek closed 3 years ago
WHOOPSIE!!
In my sample program, I forgot to include the data argument. Changing the program to this:
const rendered = ejs.render(`
<%- include('helloworld.html') %>
`, {}, {
views: dirs,
filename: 'foo.html'
});
Give it correct output.
I'm trying to better integrate EJS with AkashaRender and would like to use the
include
EJS tag. What I gathered from theoptions
object that specifying theviews
attribute should cause EJS to search the named directories for the file to include.In an AkashaRender project there are several directories from which to load templates. Those directories are available as an array of path names. The directories are searched in order, and the first one containing the requested file is used. It seemed that the
views
option would be the method for integrating this model into EJS.The documentation for this option says An array of paths to use when resolving includes with relative paths. That certainly implies exactly what's needed.
But - with the implementation I made, it does not work.
Here is a test program to demonstrate the problem.
Then... in the directory you see:
The file specified in the include tag is in one of the directories named in the views attribute. But running this code, I get the following error:
Notice that setting the "filename" option simply updated the error output. Try running the script without the "filename" option, and the only change is that the error reports the filename "ejs" rather than "foo.html".