Jade - print all possible variables

微笑、不失礼 提交于 2019-12-01 23:06:49

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!