June
June

Reputation: 2217

How to access a collection from inside a "each" block in handlebars.js?

I'm trying to do like:

{{# each items }}
    {{ @index }} / {{ items.length }}
{{/ each }}

but it seems that I can't access items inside the each block.

Is there any solution on this?

Upvotes: 0

Views: 29

Answers (1)

Sergei Veit
Sergei Veit

Reputation: 61

Use construct:

{{# each items }}
    {{ @index }} / {{ ../items.length }}
{{/ each }}

Upvotes: 1

Related Questions