Closed honi closed 9 years ago
Hi @honi. Why not simply read extensions setting from opts
? You can pass it with:
bundle.transform(nunjucksify, {env: customNunjucksEnv, extensions: ['.html']})
Cool. And how do I create customNunjucksEnv
? I mean, why do I need to create a custom nunjucks env if the extensions array is passed to bundle.transform
?
@honi its just an example of another setting that is already there, if you need to create custom nunjucks environment (e.g. for your custom tags), you have to use nunjucks:
var nunjucks = require( "nunjucks" );
var customNunjucksEnv = new nunjucks.Environment();
But you also will need to implement this on the front-end.
Of course it doesn't, because that's how it is implemented at the moment.
I only suggested to pass extensions in opts
.
Just checking, wasn't sure if your suggestion wasn't working for me because of that or because I did something wrong in my testing.
Your approach does look better though. Are you interested in this feature? I can update the PR to use opts.extensions
instead of nunjucksify.extensions
.
Hi @honi ! Yes please do that. I don't think it needs to be an array though. I can't see people usding more than one extension at once. Let's just add extension
to the options hash (a string that defaults to .nunj
).
Thanks very much for this idea and for the PR!
Ups, just read your comment about extension
instead of extensions
. I though the same thing, but since browserify uses an array, I figured I'd follow the same style.
Hi, any interest in merging this so that we can install directly from npm?
@honi I guess its not merged because @dgbeck wants a single extension
in options.
Ready. I've enabled setting extension to a string or array, works both ways.
Done and done, and published in v0.2.0. Thanks, @honi !
I personally dislike the
.nunj
extension and prefer to simply use.html
for the template files. When using browserify's JS API (for example in a Gulp task), you can now configure the extension with:nunjucksify.extensions = ['.html']
Added test, but no docs, since it was not clear where to add it, and not sure how you would configure this in another setup other than Gulp.
Salute!