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)'工作?」最近的問題。 –