#69 {{each}} with tagName

Emad Ibrahim
Sep 2, 2016 · 1 min read

Guest Tip by Devin Weaver
I just learned that the {{#each}} can take tagName and class attributes!
When before you had to wrap your {{each}}:

<ul class="list-group">
{{#each items as |item|}}
<li class="list-group-item">{{item.label}}</li>
{{/each}}
</ul>

Instead you can do this with:

{{#each items tagName="ul" class="list-group" as |item|}}
<li class="list-group-item">{{item.label}}</li>
{{/each}}

This might prove useful with the tag-less component feature in a previous tip.

Credits & Links


Originally published at Ember Daily Tips.

Emad Ibrahim

Written by

Husband, Father of Twins, Published Author, Entrepreneur, Passionate Technologist, Programmer and Productivity Nut. more at https://about.me/eibrahim