正常artTemplate这套模版渲染数据用的是{{}},公司内部用的给改成了{[]}。
demo:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="js/jquery-1.11.3.js"></script>
<script src="js/template.js"></script>
<title>Document</title>
<style>
*{margin: 0;padding: 0;}
.clearfix:after{display: block;clear: both;content: "";visibility: hidden;height: 0;}
.clearfix{zoom:1;}
.fl{float: left;}
.fr{float: right;}
.touzi_free_list {height: 400px;overflow-y: auto;width: 330px;margin: 50px auto;border: 1px solid #eaeae2;}
.touzi_free_list ul li {border-bottom: 1px solid #eaeae2;overflow: hidden;clear: both;}
.touzi_free_list ul li a {display: block;padding: 16px 10px 12px;}
.touzi_free_list .audi_tt .audi_h3 {font-size: 14px;color: #333333;font-weight: normal;line-height: 22px;margin-bottom: 5px;}
.touzi_free_list .audi_tt .audi_p {font-size: 12px;color: #666666;font-weight: bold;}
</style>
</head>
<body>
<div class="touzi_free_list">
<ul id="js_auditionBox"></ul>
</div>
<script id="js_tmpAuditionItem" type="text/html">
<li>
<a href="/videoplay?id={[id]}&tid={[teacher_id]}" class="clearfix" data-id="{[id]}">
<div class="audi_tt fl">
<h3 class="audi_h3">{[updated_at]}</h3>
<p class="audi_p">讲师:{[product_title]}</p>
</div>
</a>
</li>
</script>
<script>
$.ajax({
type: 'post',
url: ***,
dataType: 'json',
success: function (data) {
var a = data.list;
var html = '';
for (var i = 0; i < a.length; i++) {
html += template('js_tmpAuditionItem', a[i]);
}
$('#js_auditionBox').append(html);
}
})
</script>
</body>
</html>