consider my json is like this:
{
    main: {
        "" : [{some_obj},{some_obj}]
    },
    secondary: {
        "key": [{some_obj},{some_obj}]
    }
}
Now my first #each will be running for main and secondary.
{{#each this}}
    -- This is for main and secondary --
    {{#each this}}
        -- This is for "" in case of main and "key" in case of secondary --
    {{/each}}
{{/each}} 
My nested #each won't work if "this" is empty as shown in my json for "main" attribute
Seems like 3.x.x had a bug that caused this. Here's the commit that fixes this in 4.0.0.
I checked these versions with the snippet below:
4.x.x: OK
3.x.x: not OK
2.0.0: OK
var data = {
  main: {
    "": [1, 2, 3]
  },
  secondary: {
    "key": [3, 4, 5]
  }
};
var compiled = Handlebars.compile(document.getElementById('temp').innerHTML);
document.write(compiled(data));
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.5/handlebars.js"></script>
<script id="temp" type="text/x-handlebars-template">
  {{#each this}}
    {{@key}}<br>
    {{#each this}}
        "{{@key}}": {{this}}<br>
    {{/each}}
  {{/each}} 
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With