你好,我想知道如何在dot.js模板引擎中渲染输出。我认为这是一个关于nodejs模板的通用问题。(阅读评论获取更多信息)。我选择这个模板引擎而不是jade或ejs,是因为它似乎是最快的引擎。
以下是我的app.js:
var express = require('express'),
app = express.createServer(),
doT = require('doT'),
pub = __dirname + '/public',
view = __dirname + '/views';
app.configure(function(){
app.set('views', view);
app.set('view options', {layout: false});
app.set('view engine', 'dot');
app.use(app.router);
});
app.register('.html', {
compile: function(str, opts){
return function(locals){
return str;
}
}
});
app.get('/', function(req, res){
//This is where I am trying to send data to the front end....
res.render('index.html', { output: 'someStuff' });
});
这是我的HTML代码:
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>Index</title>
</head>
<body>
//This is where I am trying to receive data and output it...
{{=it.output}}
</body>
</html>
我找不到关于它的好文档。这并不足够:http://olado.github.com/doT/。如果您能帮忙,那就太感谢了。这将显著提高我对于数据如何在nodejs中传递到视图的理解。谢谢。