How to use {{Yield}} helper with hash helper in ember js?

3.5k Views Asked by At

Can somebody explain with an example about yield helper with hash which is used while using with components in emberjs ?

3

There are 3 best solutions below

0
Magaesh On BEST ANSWER

Link to using hash helper with yield in ember components.

Yield is used to share data within your component with the content it is wrapping and It's used only in block form of components.

Hash helper is used to create object. The hash helper is a generic builder of objects, given hash arguments.

2
jelhan On

Using {{yield}} is discussed in Ember Guides including a small example. You can find another, more detailed example in tutorial application that is part of Ember Guides.

3
Esteban Borai On

Implement yield in your template.hbs:

{{yield (hash
  foo=(component "path/to/component/foo")
  bar=(component "path/to/component/bar")
)}}

And you can instance it like this:

{{#baz
  as |x|
}}
  {{x.foo}}
  {{x.bar}}
{{/baz}}

Hope it helps!