我想预编译下划线模板并将它们包含在 grunt-browserify 的 app.js 目标文件中。
我知道 Handlebars 模板有“transform:hsbfy”选项,但如何对下划线模板执行相同操作?
我尝试使用node-underscorify但没有成功
最佳答案
您应该使用选项transform: ['node-underscorify']
。
browserify: {
app: {
files: {
'dist/js/app.js': ['app/main.js']
},
options: {
transform: ['node-underscorify'],
debug: true,
external: ['jquery', 'underscore', 'backbone', 'backbone.marionette']
}
}
}
然后在您的模块之一中,您可以加载如下模板:
var template = require('./template.html');
$('#el').html(template({key: 'value'});
关于javascript - 在 grunt browserify 中使用下划线模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22510246/