Jade - 打印所有可能的变量 [英] Jade - print all possible variables

查看:27
本文介绍了Jade - 打印所有可能的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够显示当前加载的玉文件可以访问的所有可用变量.

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.

推荐答案

locals 分配给自身的属性

Assign that locals onto a property of itself

app.use(function locals(req, res, next) {
    res.locals.locals = res.locals;    
    next();
});

然后只需访问您的 Jade 模板中的 locals.

Then simply access locals in your Jade template.

这篇关于Jade - 打印所有可能的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆