Sau this answer, tôi đã viết một helper nhưLàm thế nào để sử dụng Handlebars trợ lý ternary?
module.exports.register = function (Handlebars) {
Handlebars.registerHelper('ternary', function(test, yes, no) {
return test ? yes : no;
});
};
tôi chắc chắn rằng các helper được nạp và được xác định nhưng không thể tìm ra cú pháp để sử dụng nó. Tôi đã cố gắng sử dụng nó như
<div>{{ternary(true, 'yes', 'no')}}</div>
nhưng cung cấp cho một assemble build lỗi
Warning: Parse error on line 10:
...<div>{{ternary(true, 'yes',
----------^
Expecting 'ID', 'DATA', got 'INVALID' Use --force to continue.
cú pháp thích hợp để sử dụng một helper như vậy là gì?