// In your app.js etc.
app.locals.title = "My App";
app.locals({
version: 3,
somefunction: function() {
return "function result";
}
});
// Then in your templates (shown here using a jade template)
=title
=version
=somefunction()
// Will output
My App
3
function result
app.use(function(req, res, next) {
app.set('error', req.flash('error'));
next();
});
app.locals.version = 3;
app.locals.somefunction = function() {
return "function result";
}
res.locals.user = req.isAuthenticated() ? req.user : null;
res.locals.userSettings = {
backgroundColor: 'fff'
}