This commit is contained in:
贤心
2022-05-18 22:35:13 +08:00
parent ce805ee6b3
commit 902aea37d9
49 changed files with 861 additions and 613 deletions

View File

@@ -1,8 +1,5 @@
/**
@Name : laytpl 模板引擎
@LicenseMIT
* laytpl 模板引擎
*/
layui.define(function(exports){
@@ -79,7 +76,7 @@ layui.define(function(exports){
str = str.replace(exp(config.open+'|'+config.close), '');
if(/^=/.test(str)){
str = str.replace(/^=/, '');
start = '"+_escape_(';
start = '"+laytpl.escape(';
}
return start + str.replace(/\\(.)/g, '$1') + ')+"';
});
@@ -87,8 +84,8 @@ layui.define(function(exports){
tpl = '"use strict";var view = "' + tpl + '";return view;';
try{
that.cache = tpl = new Function('d, _escape_', tpl);
return tpl(data, tool.escape);
that.cache = tpl = new Function('d, laytpl', tpl);
return tpl(data, tool);
} catch(e){
delete that.cache;
return tool.error(e, tplog);
@@ -98,7 +95,7 @@ layui.define(function(exports){
Tpl.pt.render = function(data, callback){
var that = this, tpl;
if(!data) return tool.error('no data');
tpl = that.cache ? that.cache(data, tool.escape) : that.parse(that.tpl, data);
tpl = that.cache ? that.cache(data, tool) : that.parse(that.tpl, data);
if(!callback) return tpl;
callback(tpl);
};