Using dotjs in express



我想用dotjs代替翡翠为Express

我改变

app.set('view engine', 'jade');

app.set('view engine', 'html');    
app.engine('html', dot.compile);

但它没有加载很长一段时间,我没有得到响应;

怎么了

一个简单的方法是使用express-dot:

npm install express-dot

和在app.js中:

var doT = require('express-dot');
// (optional) set globals any thing you want to be exposed by this in {{= }} and in def {{# }}
doT.setGlobals({ ... });
app.set('view engine', 'dot' );
app.engine('dot', doT.__express );

当然,建议你自己写,就像亨利将军说的。
因为如果你这样做,你会更好地理解express和dot。
express-dot不支持预编译,所以我在我的Github repo中有一个简单的预编译示例。好运。

最新更新