How to find Array length inside the Handlebar templates?

Abhidev picture Abhidev · Mar 15, 2013 · Viewed 80.2k times · Source

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","def","ghi","jkl"] 
}

Now in my template I want to find the length of this array. Something like:

{{#each item}}
   {{ array.length }}
{{/each}}

Couldn't find it in the Handlebars documentation.

Answer

Abhidev picture Abhidev · Mar 15, 2013

My Bad....

{{array.length}} actually worked inside the template. Should have checked/tested it before posting it here.