Underscore.jsにはejsやjadeのようなコンパイル機能はありませんが、Node.jsモジュールとして動作します。誰かがExpressアプリケーションの中で動作させる方法の例を教えてください?Node.js Expressの例では、Underscore.jsをビューエンジンとして登録していますか?
8
A
答えて
20
var _ = require('underscore');
app.register('.html', {
compile: function (str, options) {
var template = _.template(str);
return function (locals) {
return template(locals);
};
}
});
4
これでExpress 3.0では、少し異なります。簡単な解決策: https://github.com/haraldrudell/uinexpress
npm install uinexpress
その後、
app.configure(function() {
app.engine('html', require('uinexpress').__express)
app.set('view engine', 'html')
+0
親指用で、これは私のために素晴らしい仕事 –
関連する問題
注:これは、アップ特急<3足の – UpTheCreek