ejs icon indicating copy to clipboard operation
ejs copied to clipboard

includes now accept nested/paths or "absolute/.../paths"

Open tcha-tcho opened this issue 11 years ago • 5 comments

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

tcha-tcho avatar Jan 26 '14 05:01 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 :)

ForbesLindesay avatar Jan 27 '14 14:01 ForbesLindesay

Good point @ForbesLindesay !! :) I did the change! Much better! Thanks!

tcha-tcho avatar Jan 27 '14 18:01 tcha-tcho

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?

tcha-tcho avatar Jan 28 '14 01:01 tcha-tcho

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().

ForbesLindesay avatar Feb 05 '14 11:02 ForbesLindesay

This does not work. I installed EJS but it does not accept absolute paths. What do I need to do?

aysiscore avatar Nov 08 '19 19:11 aysiscore