如何在ember-cli中创建块助手

时间:2015-06-18 10:20:45

标签: ember.js ember-cli

在Ember-CLI中,我需要像这样创建一个块助手

 {{#the-helper attribute="this is attribute" }}
     <b> this is bold string </b>
 {{/the-helper}}

-helper将在内部调用另一个帮助器。

1 个答案:

答案 0 :(得分:0)

是的,组件是要走的路。

要以块形式调用组件(并且能够将内容传递到组件中),组件模板需要包含findObjectsInBackgroundWithBlock:标记,组件块内传递的任何内容都将显示在模板中。 / p>

如果使用&#34; {{yield}}&#34;生成新组件,则组件的模板默认情况下已包含ember generate component my-component标记。如果要将其添加到现有组件,只需将标签自己添加到组件的模板文件中。

要将内容传递给它,您需要调用

{{yield}}

查看文档以获取更多详细信息:http://guides.emberjs.com/v1.12.0/components/wrapping-content-in-a-component/