分类: JavaScript
2015-05-13 20:30:14
_.templateSettings = {
interpolate: /\<\@\=(.+?)\@\>/gim,
evaluate: /\<\@(.+?)\@\>/gim,
escape: /\<\@\-(.+?)\@\>/gim
};
<script id="employee-template" type="text/template">
<@=name@>
<@=position@>
<@ _.each(phones, function(i) {<@=i@>, }@>
var template_html = _.template($('#employee-template').html());
var h = $(template_html({name: item.get("name"), position: item.get("position"), phones: item.get("phones")}))
$('#employees').append( h );