I'm trying to pass an argument to a yield block, however I missing something that I don't see. Here is the case:
components/table-notes.hbs
<table>
...
<tbody>
{{#each note in notes}}
<tr>
<td>{{yield note}}</td>
...
</tr>
{{/each}}
</tbody>
</table>
elsewhere
{{#table-notes notes=model.notes}}
//do something with each note
{{/table-notes}}
Is it anything wrong or incomplete with this param passing?
Thanks in advance.
I don't think you can do this in a version prior to 1.10. In 1.10 though, you can do the following:
Declare the 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 the component that the variable is called note
as 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
You can read more about block params in components, a new feature in 1.10, here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With