在 Jade 中需要一个 javascript 库 [英] Require a javascript library inside Jade
本文介绍了在 Jade 中需要一个 javascript 库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何要求
一个库,以便它在 Jade 中工作.
How do I require
a library so that it works inside Jade.
就像我希望能够在 Jade 中使用 CircularJSON
Like if I want to be able to use CircularJSON in Jade
script var object = #{CircularJSON.stringify(object)}
- var CircularJSON = function(e,t){function l(e,t,o){var u=[],...//whole function
这对于更复杂的库来说是不切实际的,并且可能是不可能的.
which would be impractical and possibly impossible for much more complex libraries.
有没有办法以某种方式简单地require
代替它?
Is there a way to somehow simply require
it instead?
推荐答案
var myLib = require('../mylib');
response.render("index.jade", {
lib : myLib
});
index.jade
现在有 myLib 对象.现在只需像在其他任何地方一样使用即可.
index.jade
now has the myLib object. Now just use as you would anywhere else.
这篇关于在 Jade 中需要一个 javascript 库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文