You can reproduce the behavior of the following Handlebars keywords: @index , @key , @first , @last .
@index
{{#each array as |item index|}} Index of item: `{{item}}` is: `{{index}}` {{/each}}
@key
{{
@first
You can also simulate @first behavior using the ember-truth-helpers addon and using the eq helper - thanks to kristjan reinhold for this idea:
{{#each array as |item index|}} {{#if (eq index 0)}} {{else}} {{/if}} {{/each}}
Instead of (eq index 0) you can use (eq item array.firstObject) .
@last
As dwickern, you can use Ember.Array.lastObject to simulate @last behavior.
{{#each array as |item|}} {{#if (eq item array.lastObject)}} {{else}} {{/if}} {{/each}}
source share