3

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}
jeffhuber
  • 139
  • 2
  • 11
  • 1
    It can be even more succinct actually. See this answer: http://stackoverflow.com/questions/10381827/handlerbars-js-check-if-list-is-empty/11597069#11597069 – NLF Oct 26 '12 at 01:19

1 Answers1

3

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}}
Igor Pavelek
  • 1,444
  • 14
  • 22