我不知道該如何處理遞歸陣列template.and我找不到handlebarsjs的文檔什麼如何使用遞歸模板?
有我的代碼: JS:
var branch = [{ name:"firstLayerNodeA", has_branch:true, branch:[{ name:"secondLayoutNodeA", has_branch:false },{ name:"secondLayoutNodeB", has_branch:true, branch:[{ name:"thirdLayerNodeA", has_branch:true, branch:[{ //fourth Layer //fifth Layer //..... }] }] }] },{ name:"firstLayerNodeB", has_branch:false }]
HTML
<Template name="tree"> <ul> {{#each brach}} <li> name {{#if has_branch}} <ul> {{#each brach}} <li> name {{#if has_brach}} {{#each brach}} .....third layer .....fourth layer .... {{/each}} {{/if}} </li> {{/each} </ul> {{/if}} </li> {{/each}} </ul> </Template>
有好的想法,處理模板分支? 任何幫助表示讚賞。
感謝您的時間。這是個好主意! – 2013-03-10 07:23:29