|
|
|
|
!function(){var b={open:"{{",close:"}}"};var a={exp:function(f){return new RegExp(f,"g")},query:function(h,f,i){var g=["#([\\s\\S])+?","([^{#}])*?"][h||0];return d((f||"")+b.open+g+b.close+(i||""))},escape:function(f){return String(f||"").replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/'/g,"'").replace(/"/g,""")},error:function(h,f){var g="Laytpl Error:";typeof console==="object"&&console.error(g+h+"\n"+(f||""));return g+h}};var d=a.exp,e=function(f){this.tpl=f};e.pt=e.prototype;window.errors=0;e.pt.parse=function(g,i){var h=this,f=g;var k=d("^"+b.open+"#",""),l=d(b.close+"$","");g=g.replace(/\s+|\r|\t|\n/g," ").replace(d(b.open+"#"),b.open+"# ").replace(d(b.close+"}"),"} "+b.close).replace(/\\/g,"\\\\").replace(/(?="|')/g,"\\").replace(a.query(),function(m){m=m.replace(k,"").replace(l,"");return'";'+m.replace(/\\/g,"")+';view+="'}).replace(a.query(1),function(m){var n='"+(';if(m.replace(/\s/g,"")===b.open+b.close){return""}m=m.replace(d(b.open+"|"+b.close),"");if(/^=/.test(m)){m=m.replace(/^=/,"");n='"+_escape_('}return n+m.replace(/\\/g,"")+')+"'});g='"use strict";var view = "'+g+'";return view;';try{h.cache=g=new Function("d, _escape_",g);return g(i,a.escape)}catch(j){delete h.cache;return a.error(j,f)}};e.pt.render=function(h,i){var g=this,f;if(!h){return a.error("no data")}f=g.cache?g.cache(h,a.escape):g.parse(g.tpl,h);console.log();if(!i){return f}i(f)};var c=function(f){if(typeof f!=="string"){return a.error("Template not found")}return new e(f)};c.config=function(f){f=f||{};for(var g in f){b[g]=f[g]}};c.v="1.2";"function"==typeof define?define(function(){return c}):"undefined"!=typeof exports?module.exports=c:window.laytpl=c}();
|