Underscore.js 没有像 EJS 和 Jade 那样的编译函数,但可以作为 Node.js 模块使用。请问有人能提供在 Express 应用中如何使用它的示例吗?
Underscore.js 没有像 EJS 和 Jade 那样的编译函数,但可以作为 Node.js 模块使用。请问有人能提供在 Express 应用中如何使用它的示例吗?
var _ = require('underscore');
app.register('.html', {
compile: function (str, options) {
var template = _.template(str);
return function (locals) {
return template(locals);
};
}
});
npm install uinexpress
那么
app.configure(function () {
app.engine('html', require('uinexpress').__express)
app.set('view engine', 'html')