ejs
ejs copied to clipboard
includes now accept nested/paths or "absolute/.../paths"
Hello!
This small change will include absolute paths on 'includes'. Using <% include 'strings' %> ejs will use the relative path to the project root instead of relative to the file. Tests, Readme, and other changes were made.
Thank you for every thing, this code is great! :)
Best Regards Tcha-Tcho
If you started absolute paths with /
and then also based them off of the dirname
option rather than path.dirname(filename)
then it would be consistent with the way jade supports this :)
Good point @ForbesLindesay !! :) I did the change! Much better! Thanks!
Hi @ForbesLindesay ! I followed your suggestions with the difference of instead of raise an error we use the working directory as default. Maybe this pattern could be applied to jade too. What do you think?
Almost there, but it should be basedir
not baseDir
to match up with jade. The reasoning behind using basedir
is that it matches the filename
option that is already pretty standard among a huge number of templating engines.
Personally I don't like defaulting to process.cwd()
. For most use cases in node, using the current working directory is approximately the same as using a random directory. There is no guarantee it corresponds to anything. In addition to this, it's not difficult for the user to explicitly set the basedir
value to process.cwd()
.
This does not work. I installed EJS but it does not accept absolute paths. What do I need to do?