1.显示的数据
var datas = { id:"number"}
2.temp模板
<script id="template" type="text/x-handlebars-template"> {{#compare carstatusid 4}} <button onclick="onDeleteClick('{{id}}')">删除</button> {{else}} <button onclick="onClick('{{id}}')">撤销</button> {{/compare}}</script>
3.要显示的地方html
<div id="showplace"></div>
4.用js显示数据
/*first*/var temp = Handlebars.compile($("#template").html());/*second*/ //注册一个比较大小的Helper,判断data1是否等于data2 Handlebars.registerHelper("compare",function(data1,data2,options){ if(data1 == data2){ return options.fn(this); }else{ return options.inverse(this); } });/*end*/ $("#showplace").html(temp(datas));
原标题:注册一个比较大小Handlebars
关键词: