Reputation: 41
I know that this's the way to display the index of an array inside the 'each' helper:
{{#each array}}
{{@index}}
{{/each}}
My question is how to display the array length instead. Something like:
{{#each array}}
{{array.length}}
{{/each}}
By the way, the above code doesn't work. I put many things there, but nothing worked out yet.
Upvotes: 0
Views: 83
Reputation: 1091
You can just use @last
{{#each array}}
{{#if @last}} this is the last item {{/if}}
{{/each}}
https://handlebarsjs.com/guide/builtin-helpers.html#each
Upvotes: 0