0

I'm using Ember v2.5.1.

I'm tryng this solution for my necessity to use two custom yields in same component:

How can I yield multiple pieces of content into an ember.js component template?

This is my code:

// component 
{{#father-component as |f|}}
  {{#f.left-content}} 
    This is a content
  {{/f.left-content}}
  {{#f.right-content}}
    This is a another content
  {{/f.right-content}}
{{/father-component}}

// father-component
<div class="left">
  {{yield (hash left-content = (component "foo-content"))}}
</div>
<div class="right">
  {{yield (hash right-content = (component "foo-content"))}}
</div>

// foo-content 
{{yield}}

In https://ember-twiddle.com/ this works nicelly, but in my localhost this dosn't works and return this error

Assertion Failed: A helper named 'f.right-content' could not be found

Some help?

I work with app exporting the components, and the path js and hbs separetly.


Edit

When I add {{log f}} in parent component this happens.

enter image description here

MarceloBoni
  • 241
  • 1
  • 7
  • 16

1 Answers1

1

There is an issue in ember repo discussing the trick you are using for multiple yields. Robert Jackson (@rwjblue), who is a member of the ember's core team, said in a comment that this technique only worked due to a bug that has been fixed in Ember 3.6. I haven't double checked but I would guess that the bug was added after 2.5.1, which you are using. The Ember Twiddle seems to support only versions in which this bug was alive.

TL;DR: If you want to use that approach you need to upgrade to a version that has this bug included. But I would strongly advise not to do so cause it's not supported and won't work with Ember 3.6+.

It's to sad that Yieldable named blocks RFC isn't implemented yet. You could track the status in the related tracking issue. As far as I know there is also no polyfill available (yet).

jelhan
  • 6,149
  • 1
  • 19
  • 35