In my controller I have a list of strings like this:
columns : ['name', 'description']
I want to filter what is displayed in the template based on this list:
{{#each m in controller.model}}
{{#each col in controller.columns}}
<td>{{m[col]}}</td>
{{/each}}
{{/each}}
Of course {{m[col]}}
is not valid code but you get the idea. How might I achieve this?
This code is generic so I have no way of telling what the columns array contains before hand.
You can create a bound helper as follows:
Then, you can use it in your template as follows:
Working example on jsbin here
If you want the data bound to the template so that it updates when the data changes, use a small component as follows:
Notice that you have to manually specify each property you are binding to.
Component template:
Then, you can use it in your template as follows: