node.jsexpress-handlebars

Handlebars.js: nested {{#each}} doen't work


Note: I'm using express-handlebars

My test data for render: data: [[1,2], [3,4], [5,6] ];

My .hbs tempalte:

{{#each data}}
  <div>
  {{#each inner}}
    inside - {{this}}
  {{/each}}
  </div>
{{/each}}

Outer #each works just fine, but the inner is acting like there is no data to render.

I've looked into similar questions/examples, all are using the same syntax.

There are no errors and in others ways hb works fine.


Solution

  • My solution was to use names for #each variables:

    <div>
      {{#each data as |nums|}}
        {{#each nums as |num|}}
          <div>! {{num}} </div>
        {{/each}}
      {{/each}}
    </div>