Steam Leakage

I am trying to pass an argument to the yield block, but I am missing something that I don’t see. Like this:

components / table-notes.hbs

<table>
   ...
  <tbody>
    {{#each note in notes}}
      <tr>
        <td>{{yield note}}</td>
        ...
      </tr>
    {{/each}}
   </tbody>
 </table>

in the other place

{{#table-notes notes=model.notes}}
  //do something with each note
{{/table-notes}}

Is this something wrong or incomplete with passing this parameter?

Thanks in advance.

+4
source share
1 answer

I do not think that you can do this in versions prior to 1.10. However, in 1.10 you can do the following:

Declare a component template and yield

<script type="text/x-handlebars" id="components/table-notes">
   {{#each notes as |note|}}
    {{ yield note }}
   {{/each}}
</script>

And also declare in the template using components called a variable noteas follows:

<script type="text/x-handlebars" data-template-name="index">    
  {{#table-notes notes=model.notes as |note|}}
    <h3>{{ note }}</h3>
  {{/table-notes}}
</script>

Working example here

, 1.10, .

+8

All Articles