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;
});
 
 

 

原文地址:https://www.cnblogs.com/zhilu/p/14203338.html