我有这样的骨干模型
var PeopleModel = Backbone.Model.extend({
defaults: {
"people": [
{ "username": "alan", "firstName": "Alan", "lastName": "Johnson", "phone": "1111", "email": "alan@test.com" },
{ "username": "allison", firstName: "Allison", "lastName": "House", "phone": "2222", "email": "allison@test.com" },
{ "username": "ryan", "firstName": "Ryan", "lastName": "Carson", "phone": "3333", "email": "ryan@test.com" },
{ "username": "ed", "firstName": "Edward", "lastName": "Feild", "phone": "4444", "email": "ed@test.com" },
{ "username": "phil", "firstName": "Philip", "lastName": "Doom", "phone": "5555", "email": "phil@test.com" },
{ "username": "gerald", "firstName": "Gerald", "lastName": "Butler", "phone": "6666", "email": "gerald@test.com" }
],
"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.我们有类似的东西,我的意思是underscore.js模板引擎的部分吗?
2.如果是,我们如何在underscore.js模板引擎中实现partial