eg: var app={}; app.tempEngine= (function () { var pattern = /\{(\w*[:]*[=]*\w+)\}(?!})/g; return function (template, json) { return template.replace( ...
eg:
var app={};
app.tempEngine= (function () {
var pattern = /\{(\w*[:]*[=]*\w+)\}(?!})/g;
return function (template, json) {
return template.replace(pattern, function (match, key, value) {
return json[key];
});
}
})();
var template='<div>{name}</div>\
<div>{ege}</div>\
',data={
name:"dabingzi",
ege:28
}
$(app.tempEngine(template, data));
...../
...../
<div>dabingzi</div>\
<div>28</div>