han*_*ast 4 template-engine handlebars.js assemble grunt-assemble
我正在使用装配了车把1.3.0的装配 0.4.17.
我正在尝试添加一个自定义手柄助手,如此处所述.
所以我把它添加到我的Gruntfile(在文件的底部,在...之外module.exports = function(grunt) {)
Gruntfile.js
module.exports.asdf = function (str) { return 'asdf here!'; };
Run Code Online (Sandbox Code Playgroud)
并将其添加到
index.hbs中
{{#asdf}}
bobo
{{/asdf}}
Run Code Online (Sandbox Code Playgroud)
我建议asdf here!将在生成的html中显示,但它不会,而是只打印一个空白行.我也试过这个module.exports.register = function (Handlebars, options)方法,但是这个方法也不行.我是否需要添加其他东西才能添加此车把助手?
我是Assemble和grunt and handlebar的新手,所以我可能只是错过了那个显而易见的东西
应该在另一个文件中声明帮助程序并将其添加到helpers汇编目标中的选项:
我-helper.js
module.exports.asdf = function (str) { return 'asdf here!'; };
Run Code Online (Sandbox Code Playgroud)
Gruntfile.js
grunt.initConfig({
assemble: {
options: {
helpers: ['./my-helper.js']
},
someTarget: {
...
}
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1872 次 |
| 最近记录: |