Looping through a multidimensional array in Handlebars.js

user1179321 picture user1179321 · Mar 17, 2013 · Viewed 24.6k times · Source

I have the server passing back this JSON and I'm not sure how to loop through a 2-dimensional array in Handlebars.

"userSurvey":[[1],[2],[3]]

I know to use {{#each userSurvey}} but then how would I go about do the arrays inside the usersurvey object?

Answer

Simon Boudrias picture Simon Boudrias · Mar 17, 2013

You'd have to loop 2 times:

{{#each userSurvey}}
  {{#each this}}
    {{ this }}
  {{/each}}
{{/each}}