【发布时间】:2014-06-19 23:43:28
【问题描述】:
我希望能够将一个全局对象传递给玉模板
让我们说:
app.get("/", function(req, res){
var options = {
chGlobal : {// this is the object i want to be a global
"property1" : 1,
"property2" : 2,
"property3" : 3,
}
};
jade.renderFile(__dirname +'/tpl/main.jade', options, function (err, html) {
console.log(err, html);
if (err)
{
throw err
}
else
{
res.send(html);
}
});
});
我希望能够在加载的其他脚本中使用“chGlobal”。就好像 chGlobal 是在全局范围内定义的一样。
谢谢
【问题讨论】:
-
你有什么理由要手动编译jade吗?
-
手动编译jade是什么意思?我刚开始使用玉,这是我知道如何使用它的唯一方法。
标签: javascript node.js express pug