-
Notifications
You must be signed in to change notification settings - Fork 353
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
nunjucks deprecated render function #313
Comments
Hi @gillesgw, I didn't really understand why that code was there when I first saw it either. After looking at the issue you linked, then following it to the PR that added the code, I noticed there was a new note added to the README.md giving a hint at what to do. It suggests passing the configured environment on If you have the time and could dig into nunjucks a little more to see if there is a way to detect the difference between a normal I think this would be the immediate solution, but I'm also thinking of ways to refactor consolidate to make it easier and more intuitive to pass your own configured engine instance. |
Hi @doowb, thanks for your answer! It was my first thought too, but the project I'm in is a took over project and in my refactoring, I'm switching from ejs to nunjuncks : so for now, I have old pages working with ejs and new pages with nunjuncks, thanks to consolidate. Thing is, settings.views is used by ejs views... That made me thinking that this could be improved anyway, because shouldn't we be able to have a custom nunjuncks instance AND override settings.view if needed ? Your idea to detect if it's a brand new nunjucks instance or an "env" configured instance seems to be the way to go for me. I'll try to see that as soon as I can! |
We have forked this repository for maintenance and released it under PR welcome at the new repo once new release is published today! |
Hi,
I'm using consolidate with express and nunjucks : I need for some pretty simple cases to configure my own instance of nunjucks, for adding custom filters among other things.
I can see a way in the doc, but it doesn't work, I have a "engine.configure is not an option" error, as describe in #244 , marked as resolved.
I digged a little "exports.nunjuncks.render" in lib/consolidate.js, and maybe I'm missing something, but if I comment quite almost the function, it seems to works perfectly :
in my app :
const cons = require('consolidate');
const nunjucks = require('nunjucks');
cons.requires.nunjucks = nunjucks.configure();
// cons.requires.nunjucks.addFilter('foo') ...
app.engine('njk', cons.nunjucks);
and in consolidate : /lib/consolidate.js :
`exports.nunjucks.render = function(str, options, cb) {
return promisify(cb, function(cb) {
});
};`
Is there a reason to keep this code, and if so, maybe we need to adapt it ? I didn't digged enough and I'm new to consolidate and nunjucks, but I can try to investigate.
The text was updated successfully, but these errors were encountered: