<!-- 使用块调用 -->
{{#my-component}}
Hi Jen!
{{/my-component}}
<!-- 不使用块调用 -->
{{my-component}}
{{#if (has-block)}}
Welcome {{yield}}, we are happy you're here!
{{else}}
Hey you! You're great!
{{/if}}
<!-- 也可以使用驼峰表示 (hasBlock) -->
2.hasBlockParams
通过此参数可以让其他调用该组件时选择:
1. 使用块参数
2. 不使用块参数
<!-- 使用块参数 -->
{{#my-component as |favoriteFlavor|}}
Hi Jen!
{{/my-component}}
<!-- 不使用块参数 -->
{{#my-component}}
Hi Jenn!
{{/my-component}}
{{#if (has-block-params)}}
Welcome {{yield this.favoriteFlavor}}, we're happy you're here and hope you
enjoy your favorite ice cream flavor.
{{else}}
Welcome {{yield}}, we're happy you're here, but we're unsure what
flavor ice cream you would enjoy.
{{/if}}