Skip to content

Commit

Permalink
[DOC release] Document on index block param for each helper
Browse files Browse the repository at this point in the history
(cherry picked from commit 706a4d5)
  • Loading branch information
Yuvaraja Balamurugan authored and rwjblue committed Jan 12, 2016
1 parent 2356dd6 commit 8329403
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/ember-htmlbars/lib/helpers/each.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import decodeEachKey from 'ember-htmlbars/utils/decode-each-key';
of the base Handlebars `{{#each}}` helper.
The default behavior of `{{#each}}` is to yield its inner block once for every
item in an array.
item in an array passing the item as the first param to the block.
```javascript
var developers = [{name: 'Yehuda'},{name: 'Tom'}, {name: 'Paul'}];
Expand All @@ -36,6 +36,16 @@ import decodeEachKey from 'ember-htmlbars/utils/decode-each-key';
{{/each}}
```
During iteration, the index of each item in the array is provided as a second block param.
```handlebars
<ul>
{{#each people as |person index|}}
<li>Hello, {{person.name}}! You're number {{index}} in line</li>
{{/each}}
</ul>
```
### Specifying Keys
The `key` option is used to tell Ember how to determine if the array being
Expand Down

0 comments on commit 8329403

Please sign in to comment.