Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handlebars.js - {{#each data}} nested in {{#if data}}

I would like to be able to do below with Handlebars.js. Is this possible?

{{#if data}}

   {{#each data}}
     do something here
   {{/each}}

{{/else}

   No data, sorry!

{/if}
like image 870
jeffhuber Avatar asked Feb 04 '26 07:02

jeffhuber


1 Answers

Of course, check here: http://jsfiddle.net/PXQUA/

And you have few typos in your template:

{{#if data}}
  {{#each data}}
    {{this}}
  {{/each}}
{{else}}
  No data, sorry!
{{/if}}
like image 186
Igor Pavelek Avatar answered Feb 07 '26 18:02

Igor Pavelek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!