[英]Using dotjs in express
I want to use dotjs to replace Jade for Express 我想用dotjs代替Jade for Express
I changed 我变了
app.set('view engine', 'jade');
to 至
app.set('view engine', 'html');
app.engine('html', dot.compile);
but it isn't loading for a long time and I'm not getting a response; 但是它已经加载了很长一段时间,并且没有得到回应。
what's wrong with it ? 它出什么问题了 ?
A simple way is to use express-dot: 一种简单的方法是使用express-dot:
npm install express-dot
and in your app.js: 并在您的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 );
Of cause, it is suggested that compose your own as generalhenry said. 当然,建议您按照自己的概论来撰写。
Becase if you do that , you will understand express and dot better. 如果这样做,您将更好地理解表达和点。
express-dot do not support pre-compile, so I have a simple pre-compile example in my Github repo. express-dot不支持预编译,因此我在Github存储库中有一个简单的预编译示例 。
Good luck. 祝好运。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.