var PeopleModel = Backbone.Model.extend({
defaults: {
"people": [
{ "username": "alan", "firstName": "Alan", "lastName": "Johnson", "phone": "1111", "email": "[email protected]" },
{ "username": "allison", firstName: "Allison", "lastName": "House", "phone": "2222", "email": "[email protected]" },
{ "username": "ryan", "firstName": "Ryan", "lastName": "Carson", "phone": "3333", "email": "[email protected]" },
{ "username": "ed", "firstName": "Edward", "lastName": "Feild", "phone": "4444", "email": "[email protected]" },
{ "username": "phil", "firstName": "Philip", "lastName": "Doom", "phone": "5555", "email": "[email protected]" },
{ "username": "gerald", "firstName": "Gerald", "lastName": "Butler", "phone": "6666", "email": "[email protected]" }
],
"company": {"name": "Random Corp."},
"country": "England"
}
});
且低于骨干模型是我的模板
<script id="people-template" type="text/x-handlebars-template">
{{#each people}}
{{> person}}
{{/each}}
</script>
<script id="person-partial" type="text/x-handlebars-template">
<div class="person">
<h2>{{fullName}} </h2>
<div class="phone">{{phone}}</div>
<div class="email"><a href="mailto:{{email}}">{{email}}</a></div>
</div>
我这是怎么实现的使用handlebars.js部分。
我的问题
1.Do我们有类似的事情,我的意思是柜面underscore.js模板引擎的谐音?
2,如果这样,我们如何实现underscore.js模板引擎
谢谢你耐心地回答我的问题,你的小提琴帮了不少忙。我完全忘记了为这种情况使用“窗口”。再次请注意 – bhargav
请注意,数据作为第二个参数的'_.template()'的双参数版本已从版本1.7开始删除。尽管如此,这种方法仍然很有用。 –
@PeterV.Mørch:谢谢你的提醒。我实际上回答了一些“为什么'_.template(tmpl,data)'工作?”最近的问题。 –