-
Notifications
You must be signed in to change notification settings - Fork 513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
includes now accept nested/paths or "absolute/.../paths" #157
base: master
Are you sure you want to change the base?
Conversation
If you started absolute paths with |
Good point @ForbesLindesay !! :) I did the change! Much better! Thanks! |
@@ -328,7 +328,9 @@ exports.renderFile = function(path, options, fn){ | |||
*/ | |||
|
|||
function resolveInclude(name, filename) { | |||
var path = join(dirname(filename), name); | |||
name = name.replace(/(\'|\")/ig,""); | |||
if (name[0].match(/(\/)/)) var dir = process.cwd(); //absolute path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is equivalent to if (name[0] === '/')
no need to match against a regex.
I also think instead of process.cwd()
it's better to have resolveInclude
take an extra argument of basedir
and pass options.basedir
as the value of that argument.
The code we use for jade is: https://github.com/visionmedia/jade/blob/master/lib/parser.js#L421-L428
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That way it's up to the user to specify what the "root" of an application is, which might not always be the current working directory.
…in different path of current working directory of the process - jade pattern.
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 Personally I don't like defaulting to |
This does not work. I installed EJS but it does not accept absolute paths. What do I need to do? |
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