kof/node-jqtpl — Issue #46: {{layout}} tag fails with Express (2.5.6) caching
Author: tikonen
Created: 2012-01-18 19:25:16+00:00
State: open

It seems that tag and partial methods use wrong context in jqtpl.express.js. Code demonstrates the issue

testserver.js

var express = require('express');
var app = express.createServer();

app.set('view cache', true);
app.set('view engine', 'html');
app.set('view options', { layout: false })
app.set('views', '.');
app.register('.html', require('jqtpl').express);

var count=0;
app.get('/', function(req, res){
count++;
return res.render('main', {
count: count, title: 'Title', hello: 'Hello World'
} );
});

app.listen(8080);
console.log('Go to http://localhost:8080/ and keep reloading')

main.html template

{{layout "mylayout"}}
${hello}

mylayout.html template

${title} {{html body}} Request no: ${count}

Run the server with ```node testserver.js``` . The second request on server will fail with following exception

TypeError: Property 'layout' of object #