我会用这个:http ://handlebarsjs.com/expressions.html#subexpressions
{{outer-helper (inner-helper 'abc') 'def'}}
但是流星给了我一个错误......有一些使用嵌套助手的解决方案或解决方法吗?
谢谢!
我会用这个:http ://handlebarsjs.com/expressions.html#subexpressions
{{outer-helper (inner-helper 'abc') 'def'}}
但是流星给了我一个错误......有一些使用嵌套助手的解决方案或解决方法吗?
谢谢!
现在可以使用 1.2 版
<p>
Together we have
{{pluralize (add myWidgetCount yourWidgetCount), "widget"}}
</p>
嵌套助手:如果有一个位置参数后跟其他(位置或关键字参数),则使用普通助手参数调用约定在其他参数上调用第一个参数。
将 helperB 传递给 helperA
{{helperA helperB}}
将带有参数 x 的“helperB”传递给 helperA
{{helperA helperB x}}
将带有参数 x=false 的“helperB”传递给 helperA
{{helperA helperB x=false}}
空格键包含和块参数
我认为这部分文档:http://docs.meteor.com/#ui_registerhelper,这部分http://docs.meteor.com/#template_helpers应该回答你的问题。
此外,流星模板语言称为spacebars,虽然灵感来自handlebars,但它有一些不同之处,更多内容请阅读:https ://github.com/meteor/meteor/blob/devel/packages/spacebars/README.md
这将给我们:
// template
<template name="_maybeDiv_wrapInDiv">
<div>
{{> UI.contentBlock}}
</div>
</template>
<template name="_maybeDiv_noop">
{{> UI.contentBlock}}
</template>
// client code
UI.registerHelper('maybeDiv', function () {
var isBlock = this.valueOf();
if (isBlock)
return Template._maybeDiv_wrapInDiv;
else
return Template._maybeDiv_noop;
});
你可以像这样使用它
{{#maybeDiv true}}
contents
{{/maybeDiv}}