我正在尝试尽可能多地从文档中复制,尽管我正在使用带有主干的rails应用程序中的handlebars.js。
我从车把示例中收集了一个集合。
var list = { people: [ {name: "Alan"}, {name: "Allison"}, {name: "Ryan"} ], group: "Bloggers" };
我将此系列传递给把手
if(list.people.length >0){ var showList = HandlebarsTemplates['htmlList'](list); console.log(showList); $('div#holdList').html(showList); } },
在我的hbr文件中,我有
<ul> this gets output {{#each list.people}} this doesn't, but should. <br/gt; {{/each}} </ul>
我的输出显示'this gets output',但是我无法让把手进入循环并显示'这不是但应该。'
我做错了什么?
答案 0 :(得分:2)
你应该在模板中迭代人而不是list.people。