i trying replicate following handlebars syntax aurelia
<td><span>{{#each person.colours}}{{name}}{{#unless @last}}, {{/unless}}{{/each}}</span></td>
i know there repeat.for
attribute html elements don't want repeat element in case.
so given object of folowing shape:
{ firstname: "john", lastname: "doe", colours: [ { id: 1, name: "red" }, { id: 2, name: "green" } ] }
should generate following output:
<td><span>red, green</span></td>
<require from="./colour-names-value-converter"></require> <td><span>${person.colours | colournames}</span></td>
colour-names-value-converter.js
export class colournamesvalueconverter { toview(colours) { return colour.map(c => c.name).join(', '); } }
Comments
Post a Comment