I have an express 3 application running good, but there is something going wrong when i refresh the site for the second time.
var x = {footer:"footer", header:"header"}
exports.index = function(req, res){
res.render("index.html", {jow: "ieps", partials:x})
}
When i go to my site for the first time then all is fine and all partials render great.
But when refreshing i have this error:
Error: ENOENT, open '/Users/kevinvanhove/Documents/work/projects/basing/business/klanten/javascript/nodeJS/express/basing/views/<h2>wow</h2>.html'
However, when removing the x variable and adding the object literal directly to the res.render parameter list all works fine again.
exports.index = function(req, res){
res.render("index.html", {jow: "ieps", partials:{footer:"footer", header:"header"}})
}
UPDATE: index.html view
{{> header}}
<h1>jow en {{jow}}</h1>
{{> footer}}
See this vine for a quick overview:
Some insight would be greatly appreciated, thank you.
Like commented above, Consolitate.js alters the original object: https://github.com/tj/consolidate.js/blob/master/lib/consolidate.js#L124
I've worked around this problem by always using a clone of partials:
// ...
var _ = require('underscore');
var partials = { layout: 'layout' };
app.get('/', function(request, response) {
response.render('index', { partials: _.clone(partials) });
});
It's not the best solution, but it works.
consolidate.js probably should use a different object for caching the partial content. And I managed to do this for hogan, but this wouldn't work with all the other engines.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.