How to get index in Handlebars each helper?
How to get index in Handlebars each helper?
I know this already has an accepted answer, but in case someone stumbles on this thread while looking for an answer to this question. In the newer versions of Handlebars index (or key in the case of object iteration) is provided by default with the standard each helper. The index of the current array item has been available for some time now via @index: {{#each array}} {{@index}}: {{this}} {{/each}} For object iteration, use @key instead: {{#each object}} {{@key}}: {{this}} {{/each}}tag: handlebars
沒有留言:
張貼留言