I have a Handlebars template which is rendered using a json object. In this json I am sending an array. Like this:
var json = {
\"array\":[\"abc\"
In this case you need to reference the parent variable of the each from within the each block:
{{#each array}}
{{../array.length}}
{{/each}}
I think your variable being named "array" is probably conflating the issue as well. Let's assume some different JSON just to clarify:
var json = {
"fruit":["apple","orange","banana"]
};
So then doing this:
{{#each fruit}}
- {{this}} {{@index}} {{../fruit.length}}
{{/each}}
Would yield:
- apple 0 3
- orange 1 3
- banana 2 3