I am playing with the node-express-boilerplate project and trying to convert it to use dust.js templates. I have dust.js render simple views with Express@3.x and dustjs-linkedin, however am stuck on converting helpers to be used inside dust.js templates.
I redefined the code starting @ https://github.com/mape/node-express-boilerplate/blob/master/server.js:144
to conform with the new Express@3.x version (using https://github.com/visionmedia/express/wiki/Migrating-from-2.x-to-3.x as a guide), as such:
app.configure(function() {
app.use(function(req, res, next) {
res.locals.assetsCacheHashes = function(req, res) {
return assetsMiddleware.cacheHashes;
}
res.locals.session = function(req, res) {
return req.session;
}
res.locals.error = function(err, req, res, next) {
// ...
}
next();
});
});
I would assume that in dust.js template, I could use {session} to test the session or {assetsCacheHashes} to test and print them out, but that does not seem to be the case.
Any hints as to what I am doing incorrectly? Should I use dust.js helpers instead? If so, can someone suggest an example? Thanks!
I believe you are defining your locals incorrectly.
Try this: