我正在尝试使用 index: {{#eachIndex}} 来实现每个,但我发现的所有代码示例似乎都已被弃用:
UI.registerHelper('eachIndex', function () {
var withIndex = _.map(this, function(x, i) {
x.index = i;
return x;
});
return UI.Each(function() {
return withIndex;
}, UI.block(null), UI.block(null));
});
UI.block 未定义。
我有另一个片段试图将参数传递给模板,但它也失败了,所以我猜我完全错了:
UI.registerHelper('clearfix', function () {
return UI.With((function() {
return {attributes:{class:this.col}};
}), Template._clearfix);
});