Old Guides - You are viewing the guides for
Ember
v1.10.0.
If you need to enumerate over a list of objects, use Handlebars' {{#each}}
helper:
<ul>
<li>Hello, !</li>
</ul>
The template inside of the {{#each}}
block will be repeated once for
each item in the array, with the each item set to the person
keyword.
The above example will print a list like this:
<ul>
<li>Hello, Yehuda!</li>
<li>Hello, Tom!</li>
<li>Hello, Trek!</li>
</ul>
Like everything in Handlebars, the {{#each}}
helper is bindings-aware.
If your application adds a new item to the array, or removes an item,
the DOM will be updated without having to write any code.
The {{#each}}
helper can have a matching {{else}}
.
The contents of this block will render if the collection is empty:
Hello, !
Sorry, nobody is here.