Magaesh
Magaesh

Reputation: 519

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

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

Upvotes: 3

Views: 3810

Answers (3)

Esteban Borai
Esteban Borai

Reputation: 2509

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!

Upvotes: 4

Magaesh
Magaesh

Reputation: 519

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.

Upvotes: 2

jelhan
jelhan

Reputation: 6338

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.

Upvotes: 1

Related Questions