2011-07-26 19 views

Trả lời

20
var _ = require('underscore'); 

app.register('.html', { 
    compile: function (str, options) { 
    var template = _.template(str); 
    return function (locals) { 
     return template(locals); 
    }; 
    } 
}); 
+0

Lưu ý: Đây là cho nhanh <3 – UpTheCreek

4

Bây giờ với Express 3.0, có một chút khác biệt. Giải pháp dễ dàng: https://github.com/haraldrudell/uinexpress

npm install uinexpress 

sau đó

app.configure(function() { 
app.engine('html', require('uinexpress').__express) 
app.set('view engine', 'html') 
+0

Thumbs up, điều này làm việc rất lớn đối với tôi –