helper functions for handlebars JavaScript template engine.
each function with loop index.
<ul class="people_list">
{{#each_with_idx people}}
<li>{{this.idx}} - {{this}}</li>
{{/each}}
</ul>
Result:
<ul class="people_list">
<li>0 - Yehuda Katz</li>
<li>1 - Alan Johnson</li>
<li>2 - Charles Jolley</li>
</ul>
- start
- number of start index.
Example
<ul class="people_list">
{{#each_with_idx people start=5}}
<li>{{this.idx}} - {{this}}</li>
{{/each}}
</ul>
Result:
<ul class="people_list">
<li>5 - Yehuda Katz</li>
<li>6 - Alan Johnson</li>
<li>7 - Charles Jolley</li>
</ul>
Copyright (c) 2012 Daisuke Takaoka. MIT License.