【发布时间】:2015-04-03 23:36:44
【问题描述】:
在this answer之后,我写了一个类似的助手
module.exports.register = function (Handlebars) {
Handlebars.registerHelper('ternary', function(test, yes, no) {
return test ? yes : no;
});
};
我确定帮助程序已加载并正在定义,但无法弄清楚使用它的语法。我试过像
一样使用它<div>{{ternary(true, 'yes', 'no')}}</div>
但这会产生assemble 构建错误
Warning: Parse error on line 10:
...<div>{{ternary(true, 'yes',
----------^
Expecting 'ID', 'DATA', got 'INVALID' Use --force to continue.
使用这样的帮助器的正确语法是什么?
【问题讨论】: