3
我希望能夠在Handlebars.js中做到。這可能嗎?Handlebars.js - {{#each data}}嵌套在{{#if data}}
{{#if data}}
{{#each data}}
do something here
{{/each}}
{{/else}
No data, sorry!
{/if}
我希望能夠在Handlebars.js中做到。這可能嗎?Handlebars.js - {{#each data}}嵌套在{{#if data}}
{{#if data}}
{{#each data}}
do something here
{{/each}}
{{/else}
No data, sorry!
{/if}
當然,點擊這裏:http://jsfiddle.net/PXQUA/
而且你必須在你的模板幾個錯別字:
{{#if data}}
{{#each data}}
{{this}}
{{/each}}
{{else}}
No data, sorry!
{{/if}}
它可以更簡潔的實際。看到這個答案:http://stackoverflow.com/questions/10381827/handlerbars-js-check-if-list-is-empty/11597069#11597069 – NLF