I'm trying to build a small app to call from a config.js file containing JSON and write that data to a page based on the name key within the JSON.
app.get('/:verb', function(req, res) {
if(!!req.param.verb) {
config.data.forEach(function(o) {
var verbName = o.name,
description = o.description;
});
};
res.render('verb', {title: verbName, subtitle: description});
});
What I'm trying to do is use the verbName and description javascript variables as Jade variable in the res.render structure. As it stands this code will fail due to verbName and description not being strings.
Is it possible to include variables this way?
PS - been in express 1 week and Jade 2 days, so all ideas/solutions would be appreciated.
localsobject. So you should be able to access them by doinglocals["title"]&locals["subtitle"].localsobject. Essentially I am trying to usevar verbName = o.nameto provide data to thetitleobject. I can't get res.render to accept a variable fortitle. If that is solved using locals then that's excellent.