问题
I would like to be able to display all available variables that the currently loaded jade file has access to.
I realise this is a little odd, but there you go :)
I am not really bothered if its in the console or outputting to the page.
console.info(res.locals) //this gives back way more than jade has access to.
回答1:
Assign that locals
onto a property of itself
app.use(function locals(req, res, next) {
res.locals.locals = res.locals;
next();
});
Then simply access locals
in your Jade template.
来源:https://stackoverflow.com/questions/28267805/jade-print-all-possible-variables