artTemplate 辅助函数

自定义辅助方法

使用template.helper方法添加公用的辅助方法

template.helper(test, callback);
var html = template('test', data);
document.getElementById('content').innerHTML = html;

 

举个例子
/**
* 保留小位数
* 使用方法 <%=toFixed(val, 1) || 0%>
*/
template.helper('toFixed', function (value, num) {
return value ? value.toFixed(num) : 0;
});
 
 

 

 

posted @ 2020-12-28 20:04  之鹿喵  阅读(103)  评论(0编辑  收藏  举报