Comparing version 0.9.16 to 0.9.17
@@ -36,3 +36,3 @@ { | ||
}, | ||
"version" : "0.9.16" | ||
"version" : "0.9.17" | ||
} |
@@ -35,3 +35,3 @@ var U, RESERVED = '__ASSERT__ __CONTEXT__ __FILTER_ __OUTPUT__ __UTIL__ $_ document false global instanceof null true typeof undefined window'.split( ' ' ).reduce( function( o, k ) { | ||
parse : function( o, id, tpl ) { | ||
var d = [tpl[fn_var.dict], o], t; | ||
var s, t; | ||
@@ -47,5 +47,9 @@ if ( id instanceof __Class__ ) | ||
o[fn_var.parent] = tpl[fn_var.dict]; | ||
o[fn_var.parent] = this[fn_var.dict]; | ||
return t.parse( o ); | ||
s = t.parse( o ); | ||
delete o[fn_var.parent]; | ||
return s; | ||
}, | ||
@@ -52,0 +56,0 @@ stop : function( iter ) { iter.stop(); }, |
@@ -39,3 +39,3 @@ ;!function( util, Name, PACKAGE ) { | ||
parse : function( o, id, tpl ) { | ||
var d = [tpl[fn_var.dict], o], t; | ||
var s, t; | ||
@@ -51,5 +51,9 @@ if ( id instanceof __Class__ ) | ||
o[fn_var.parent] = tpl[fn_var.dict]; | ||
o[fn_var.parent] = this[fn_var.dict]; | ||
return t.parse( o ); | ||
s = t.parse( o ); | ||
delete o[fn_var.parent]; | ||
return s; | ||
}, | ||
@@ -56,0 +60,0 @@ stop : function( iter ) { iter.stop(); }, |
@@ -1,1 +0,1 @@ | ||
!function(e,t,n){"use strict";function j(t,n){return typeof t.indexOf=="function"&&!!~t.indexOf(n)||e.got(t,n)}function F(e){return String(e).replace(p,d)}function I(e){return R(e,Array.coerce(arguments,1))}function q(e){return D[e]||null}function R(e,t,n){return String(e).replace(n||s,function(e,n){return t[n]||""})}function U(e){return typeof e=="object"&&(e.constructor===Object||e.constructor===r)}function z(t,n,i){n||(n=e),i||(i=t);var s=-1,o=t.length,u=[],a;while(++s<o){a=n.call(i,t[s],s,t);switch(a){case null:case r:break;default:switch(typeof a){case"string":a.trim()===""||u.push(a);break;case"number":isNaN(a)||u.push(a);break;default:!e.iter(a)||e.len(a)||u.push(a)}}}return u}function W(t){return!e.empty(t)}function X(t,n){this[l]=[],this.push(e.global),n!==r&&(this.hasFallback=!0,this.fallback=n);switch(e.ntype(t)){case"object":this.push(t);break;case"array":t[v.dict]?t.map(this.push,this):this.push(t);break;default:!e.exists(t)||this.push(t)}}function V(t,n,r,i){var s=Object.keys(t=this._=Object(t)),o=s.length;if(!o)return this.stop();e.tostr(t)=="[object Object]"||(s=s.map(Number)),this.empty=!1,this.count=isNaN(i)?o:i<0?o+i:i>o?o:i,r==0||isNaN(r)?(this.firstIndex=0,this.index=-1):(this.firstIndex=r,this.index=r-2),this.index1=this.index+1,this.lastIndex=this.count===o?this.count-1:this.count,this.keys=s,!(n instanceof V)||(this.parent=n)}function $(t,n){return e.empty(n)||t.push(n),t}function J(e,t){return t.reduce(function(t,n,r,i){if(r==0)return ot(e,n);var s="",o,u=n.indexOf(":");return~u?(o=n.substring(0,u),s=n.substring(u+1)):o=n,!s||(s=", "+s.split(",").map(function(e){return ot(this,e)},e).join(", ")),I(H,tt(o),o,ot(e,t),s,v.ctx)},"")}function K(e,t){var n=[g],r;while(r=t.shift())n.push(Z(e,r,t));return n.push(m),n.join("\r\n")}function Q(e){return e.replace(x,"").replace(T,"\n").replace(N," ").trim()}function G(n,r){n.debug&&typeof e.global[w]!="undefined"&&(e.global[w].info(t+": ",n.id,", source: "),e.global[w].log(r));var i=(new Function("root","ContextStack","Iter",v.filter,v.assert,v.util,v.ctx,r)).bind(n,e.global,X,V,e.copy(n.filters,at.Filter.all(),!0),o,a);return e.def(i,"src",e.describe(r,"r")),i}function Y(e){e.currentIterKeys=[];var t=G(e,K(e,nt(e.__tpl__)));return delete e.currentIterKeys,t}function Z(e,t,n){var r;return(r=at.Tag.get(t))?(t=n.shift(),r.emit(b,e,t,n)):ut(I('"{0}"',t.replace(S,"\\$1")))}function et(e,t){t=Q(t);switch(t){case"AND":return" && ";case"OR":return" || "}return j(t,"|")||j(t,h)?(" "+t+h).replace(O,function(t){return o.blank(t)||t==h?"":J(e,Q(t).split("|"))}):ot(e,t)}function tt(e){return o[e]?v.assert:a[e]?v.util:v.filter}function nt(e){return e.replace(k,_).split(M).reduce($,[])}function rt(t,n){switch(typeof t){case"boolean":case"number":case"string":return String(t);default:switch(e.ntype(t)){case"date":return t.toDateString();case"array":return z(t,rt).join(", ");case"object":return f in t?rt(t.dict):(n=t.toString())!="[object Object]"?n:z(Object.values(t),rt).join(", ");default:switch(e.type(t)){case"htmlelement":return t.outerHTML;case"htmlcollection":return z(Array.coerce(t),function(e){return rt(e)}).join("\n")}}}return""}function it(e){return this==e||o.startsWith(this,e+".")}function st(e,t){return e.length?e.some(function(e){return e.some(it,t)}):0}function ot(e,t){var n=e.currentIterKeys||[];return t=Q(t),j(t,".call(")||C.test(t)||o.startsWith(t,'"')&&o.endsWith(t,'"')||o.startsWith(t,"'")&&o.endsWith(t,"'")||!isNaN(t)?t:o.startsWith(t,"$_.")||o.startsWith(t,"iter.")||n.length&&st(n,t)||t in i?t.replace(L,A):I('$C.get( "{0}" )',t)}function ut(e){return I("{0} += {1};",v.output,e.replace(E,"\\n"))}function at(){var e=Array.coerce(arguments),t=U(e[e.length-1])?e.pop():U(e[0])?e.shift():null;if(!(this instanceof at))return U(t)?new at(e.join(""),t):new at(e.join(""));!t||c.forEach(function(e){e in t&&(this[e]=t[e],delete t[e])},this),this.filters=t||{},this.__tpl__=e.join(""),D[ft(this)]=this,this.compiled&&(this.compiled=!1,lt(this))}function ft(e){return e.id||(e.id=I(P,++y)),e.id}function lt(e){return e.compiled||(e.compiled=!0,e._parse=Y(e)),e}function ct(e){this.compiled||lt(this),this[v.dict]=e;var t=this._parse(e);return delete this[v.dict],t}function ht(t){function r(e,t,r){!r&&e in n||(n[e]=t)}function i(e,t){switch(typeof t){case"string":r(t,arguments[2],e);break;case"object":for(var n in t)r(n,t[n],e)}return this}var n={};!U(t)||e.copy(n,t),this.all=function(){return e.copy(n)},this.add=function(){return i.call(this,!1,arguments[0],arguments[1])},this.get=function(e){return n[e]},this.replace=function(){return i.call(this,!0,arguments[0],arguments[1])}}var r,i="__ASSERT__ __CONTEXT__ __FILTER_ __OUTPUT__ __UTIL__ $_ document false global instanceof null true typeof undefined window".split(" ").reduce(function(e,t){return e[t]=!0,e},e.obj()),s=/\$?\{([^\}\s]+)\}/g,o={blank:function(t){return e.empty(t)||typeof t=="string"&&!t.trim()},contains:j,endsWith:function(e,t){e=String(e);var n=e.length-t.length;return n>=0&&e.lastIndexOf(t)==n},empty:e.empty,equals:function(e,t){return e==t},exists:e.exists,is:function(e,t){return e===t},isEven:function(e){return!(parseInt(e,10)&1)},isOdd:function(e){return!(parseInt(e,10)&1)},isTPL:function(e){return!!q(I(B,this.id,e))||!!q(e)},iterable:function(t){return e.iter(t)},notEmpty:W,startsWith:function(e,t){return String(e).indexOf(t)===0}},u={},a={inspect:function(t){switch(e.ntype(t)){case"object":case"array":console.dir(t);break;default:console.log(t)}return""},objectify:function(e,t){var n={};return n[t]=e,n},parse:function(e,t,n){var r=[n[v.dict],e],i;return t instanceof at?i=t:(t=String(t).trim(),i=q(I(B,this.id,t))||q(t)),i?(e[v.parent]=n[v.dict],i.parse(e)):this.fallback},stop:function(e){e.stop()},stringify:rt,type:function(t,n){var r=e.type(t);return typeof n=="string"?r==n:r},value:function(e,t){return Object.value(e,t)}},f="__tpl_cs_cached_keys",l="__tpl_cs_stack",c="compiled debug dict fallback id".split(" "),h="<~>",p=/([-\*\+\?\.\|\^\$\/\\\(\)[\]\{\}])/g,d="\\$1",v={assert:"__ASSERT__",ctx:"__CONTEXT__",dict:"__dict__",filter:"__FILTER__",output:"__OUTPUT__",parent:"__PARENT__",util:"__UTIL__"},m=I("return {0};\n ",v.output),g='\n"use strict";\n'+I('var $C = new ContextStack( {0}, this.fallback, this.dict ), $_ = $C.current(), iter = new Iter( null ), {1} = "", U;',v.ctx,v.output),y=999,b,w="console",E=/[\n\r]/gm,S=/(['"])/g,x=new RegExp(h,"gm"),T=/[\r\n]+/g,N=/\s+/g,C=/[\(\)\[\]\{\}\?\*\+\/<>%&=!-]/,k,L=/\.(\d+)(\.?)/g,A="['$1']$2",O=new RegExp("\\s*([^\\|]+(?:\\|[^\\|]+?)){0,}"+h,"g"),M="<__SPLIT__TEMPLATE__HERE__>",_=["","$1","$2",""].join(M),D={},P="t8-anon-{0}",H='{0}["{1}"].call( this, {2}{3}, {4} )',B="{0}.{1}";X.prototype={current:function(){return(this.top||this[l][0]).dict},get:function(t){var n,i=this[l],s=i.length,o;while(s--){n=i[s];if(t in n.cache)return n.cache[t];if((o=n.dict[t])!==r||(o=Object.value(n.dict,t))!==r)return n.cache[t]=o}return this.hasFallback?this.fallback:r},pop:function(){var t=this[l].pop().dict;return this.top=this[l][this[l].length-1],t},push:function(n){return this[l].push(this.top={cache:e.obj(),dict:n}),this}},V.prototype={empty:!0,hasNext:function(){return this.stopped||this.empty?!1:(++this.index<this.lastIndex||(this.stop().isLast=!0),this.key=this.keys[this.index1++],this.current=this.val=this._[this.key],this)},stop:function(){return this.stopped=!0,this}},e.defs(V.prototype,{first:{get:function(){return this._[this.keys[this.firstKey]]}},last:{get:function(){return this._[this.keys[this.lastKey]]}},next:{get:function(){return this._[this.keys[this.nextKey]]}},prev:{get:function(){return this._[this.keys[this.prevKey]]}},nextIndex:{get:function(){var e=this.index+1;return e<=this.lastIndex?e:r}},prevIndex:{get:function(){var e=this.index-1;return e>=this.firstIndex?e:r}},firstKey:{get:function(){return this.keys[this.firstIndex]}},lastKey:{get:function(){return this.keys[this.lastIndex]}},nextKey:{get:function(){return this.keys[this.nextIndex]}},prevKey:{get:function(){return this.keys[this.prevIndex]}}},"r"),b={assembleparts:K,clean:Q,compiletpl:G,createtpl:Y,emittag:Z,fnvar:v,formatstatement:et,get:ot,util:a,wrap:ut},at.prototype={compiled:!1,debug:!1,dict:null,fallback:"",parse:ct},e.defs(at,{m8:{value:e},escapeRE:F,format:I,get:q,gsub:R,stringify:rt},"r"),at.Assert=new ht(o),at.Filter=new ht(u),at.Statement=new ht,at.Tag=new function(){function s(t){n.forEach(o,t),e.copy(this,t),i[this.start]=this}function o(e){if(!(e in this))throw new TypeError(I("A "+t+" Tag requires an {0}",r[e]))}var n="emit end start".split(" "),r={emit:"emit function",end:"end tag definition",start:"start tag definition"},i={};this.all=function(){return e.copy(i)},this.compileRegExp=function(){var e=[],t=[],n;for(n in i)e.push(F(i[n].end.substring(0,1))),t.push(F(i[n].start.substring(1)));return k=new RegExp("(\\{["+t.join("")+"])\\s*(.+?)\\s*(["+e.join("")+"]\\})","gm")},this.create=function(e,t){return new s(e),t===!0||this.compileRegExp(),this},this.get=function(e){return i[e]}};var pt=[{start:"{{",end:"}}",emit:function(e,n,r,i){var s,o,u,a;if(r=="")throw new SyntaxError(t+" missing key in value declaration.");!wt.test(r)||(s=j(r,"|")?(r.match(bt)||dt).filter(W):r.match(bt));if(!s||s.length<=2)return e.wrap(e.formatstatement(n,r));s.shift(),a=e.formatstatement(n,s.shift()),u=vt(s.shift().toLowerCase()),o=s.join(" ");if(!u||!o)throw new SyntaxError(t+" missing tag or statement in one liner value declaration.");return u(e,n,o,i)+e.wrap(a)+vt("endif")}},{start:"{%",end:"%}",emit:function(e,n,r,i){if(r=="")throw new SyntaxError(t+" missing key in statement declaration.");var s,o,u;if(!(u=vt(r.toLowerCase()))){s=r.split(" "),u=vt(s.shift().toLowerCase());if(s.length==0&&typeof u=="string")return u;o=s.join(" ");if(!u||!o)throw s=[],u||s.push("tag"),o||s.push("statement"),new SyntaxError(t+" missing "+s.join(" and ")+" in statement declaration.")}if(!u)throw new SyntaxError(I(t+" tag: {0} does not exist.",u));return typeof u=="function"?u(e,n,o,i):u}},{start:"{[",end:"]}",emit:function(e,t,n,r){n=n.replace(mt,"$1").split("for each");var i,s,o,u,a=e.clean(n.shift()),f=e.clean(n.pop()).match(gt);return n=[],f.shift(),u=f.shift(),o=f.shift(),f.length>=2&&(s=f.shift(),i=f.shift()),n.push(vt("for")(e,t,(W(u)?u.match(yt,"$1").join(",")+" in ":"")+o,r)),!i||n.push(vt(s||"if")(e,t,i,r)),n.push(e.wrap(a.split(" ").map(function(n){return e.formatstatement(t,n)}).join(" "))),!i||n.push(vt("endif")),n.push(vt("endfor")(e,t)),n.join("")}},{start:"{:",end:":}",emit:function(e,t,n){return e.formatstatement(t,n)+";"}},{start:"{#",end:"#}",emit:function(e,t,n){return["\n/*",n,"*/\n"].join(" ")}}],dt=[],vt=at.Statement.get,mt=/\s*(,)\s*/g,gt=/^\(\s*(.*?)(?:\bin\b){0,1}(.*?)\s*\)\s*(if|unless){0,1}\s*(.*)$/i,yt=/(\w+)/g,bt=/^(.*?)\s+(if|unless)\s+(.*)|$/i,wt=/\s+(if|unless)\s+/i;pt.forEach(function(e){at.Tag.create(e,!0)}),at.Tag.compileRegExp(),function(){function i(e,t,n){return n.split(" ").map(function(n){return t(e,n)}).join(" ")}var t={"for":function(e,t,i){var s="U",o=s,u,a,f=e.clean(i).match(n),l=s,c=[];return f===null?u=i:(f.shift(),o=f.pop()||s,l=f.pop()||s,u=f.pop()||f.pop(),a=(f.pop()||"").match(r)),u=e.formatstatement(t,u),c.push(I(["","iter = new Iter( {0}, iter, {1}, {2} );","while ( iter.hasNext() ) {","$_ = iter.current;"].join("\n\r"),u,l,o)),a&&a.length>0&&(t.currentIterKeys.unshift(a),a.length<2?c.push(I("var {0} = iter.current;\n\r",a[0])):a.length>=2&&c.push(I("var {0} = iter.key, {1} = iter.current;\n\r",a[0],a[1]))),c.join("")},forempty:"\n\r}\n\rif ( iter.empty ) {\n\r",endfor:function(e,t){return t.currentIterKeys.shift(),I(["\n\r}","iter = iter.parent || new Iter( null );","$_ = iter.current || $C.current(); \n\r"].join("\n\r"),e.fnvar.util)},"if":function(e,t,n){return I("if ( {0} ) { ",i(t,e.formatstatement,n))},elseif:function(e,t,n){return I(" } else if ( {0} ) { ",i(t,e.formatstatement,n))},"else":" } else { ",endif:" }",sub:function(t,n,r,i){var s="endsub",o,u=r.trim(),a,f;return o=i.indexOf([s,u].join(" ")),o>-1||(o=i.indexOf(s)),a=i.splice(0,o+1),a.splice(a.length-2,a.length),u=I("{0}.{1}",n.id,u),f=new at("",e.copy({debug:n.debug,fallback:n.fallback,id:u},n.filters)),f.currentIterKeys=[],f.__tpl__=a.join(""),f._parse=t.compiletpl(f,t.assembleparts(f,a)),delete f.currentIterKeys,f.compiled=!0,""},unless:function(e,t,n){return I("if ( !( {0} ) ) { ",i(t,e.formatstatement,n))}},n=/^(\[[^,]+,\s*[^\]]+\]|[^\s]+)(?:\s+in\s+([^\s\[]+)){0,1}\s*(?:\[?(\d+)\.+(\d*)]*\]?){0,1}/i,r=/(\w+)/g;at.Statement.add(t),at.Statement.add("elsif",t.elseif)}(),at.Filter.add({capitalize:function(e){return e=at.stringify(e),e.charAt(0).toUpperCase()+e.substring(1).toLowerCase()},count:function(t){return e.len(t)||0},crop:function(e,t){return e=at.stringify(e),t=parseInt(t,10)||50,e.length>t?e.substring(0,t/2)+"..."+e.substring(e.length-t/2):e},def:function(e,t){return o.blank(e)?t:e},first:function(t){switch(e.ntype(t)){case"array":return t[0];case"string":return t.charAt(0)}},join:function(t,n){return e.got(t,"join")&&typeof t.join=="function"?t.join(n):t},last:function(t){switch(e.ntype(t)){case"array":return t[t.length-1];case"string":return t.charAt(t.length-1)}},lowercase:function(e){return at.stringify(e).toLowerCase()},prefix:function(e,t){return t+e},suffix:function(e,t){return e+t},truncate:function(e,t){return e=at.stringify(e),t=parseInt(t,10)||50,e.length>t?e.substring(0,t)+"...":e},uppercase:function(e){return at.stringify(e).toUpperCase()},wrap:function(e,t,n){return t+e+(n||t)}}),e.iter(n)||(n=e.ENV=="commonjs"?module:e.global),at=e.expose(at,t,n),e.expose(e,at)}(typeof m8!="undefined"?m8:typeof require!="undefined"?require("m8"):null,"Templ8") | ||
!function(e,t,n){"use strict";function j(t,n){return typeof t.indexOf=="function"&&!!~t.indexOf(n)||e.got(t,n)}function F(e){return String(e).replace(p,d)}function I(e){return R(e,Array.coerce(arguments,1))}function q(e){return D[e]||null}function R(e,t,n){return String(e).replace(n||s,function(e,n){return t[n]||""})}function U(e){return typeof e=="object"&&(e.constructor===Object||e.constructor===r)}function z(t,n,i){n||(n=e),i||(i=t);var s=-1,o=t.length,u=[],a;while(++s<o){a=n.call(i,t[s],s,t);switch(a){case null:case r:break;default:switch(typeof a){case"string":a.trim()===""||u.push(a);break;case"number":isNaN(a)||u.push(a);break;default:!e.iter(a)||e.len(a)||u.push(a)}}}return u}function W(t){return!e.empty(t)}function X(t,n){this[l]=[],this.push(e.global),n!==r&&(this.hasFallback=!0,this.fallback=n);switch(e.ntype(t)){case"object":this.push(t);break;case"array":t[v.dict]?t.map(this.push,this):this.push(t);break;default:!e.exists(t)||this.push(t)}}function V(t,n,r,i){var s=Object.keys(t=this._=Object(t)),o=s.length;if(!o)return this.stop();e.tostr(t)=="[object Object]"||(s=s.map(Number)),this.empty=!1,this.count=isNaN(i)?o:i<0?o+i:i>o?o:i,r==0||isNaN(r)?(this.firstIndex=0,this.index=-1):(this.firstIndex=r,this.index=r-2),this.index1=this.index+1,this.lastIndex=this.count===o?this.count-1:this.count,this.keys=s,!(n instanceof V)||(this.parent=n)}function $(t,n){return e.empty(n)||t.push(n),t}function J(e,t){return t.reduce(function(t,n,r,i){if(r==0)return ot(e,n);var s="",o,u=n.indexOf(":");return~u?(o=n.substring(0,u),s=n.substring(u+1)):o=n,!s||(s=", "+s.split(",").map(function(e){return ot(this,e)},e).join(", ")),I(H,tt(o),o,ot(e,t),s,v.ctx)},"")}function K(e,t){var n=[g],r;while(r=t.shift())n.push(Z(e,r,t));return n.push(m),n.join("\r\n")}function Q(e){return e.replace(x,"").replace(T,"\n").replace(N," ").trim()}function G(n,r){n.debug&&typeof e.global[w]!="undefined"&&(e.global[w].info(t+": ",n.id,", source: "),e.global[w].log(r));var i=(new Function("root","ContextStack","Iter",v.filter,v.assert,v.util,v.ctx,r)).bind(n,e.global,X,V,e.copy(n.filters,at.Filter.all(),!0),o,a);return e.def(i,"src",e.describe(r,"r")),i}function Y(e){e.currentIterKeys=[];var t=G(e,K(e,nt(e.__tpl__)));return delete e.currentIterKeys,t}function Z(e,t,n){var r;return(r=at.Tag.get(t))?(t=n.shift(),r.emit(b,e,t,n)):ut(I('"{0}"',t.replace(S,"\\$1")))}function et(e,t){t=Q(t);switch(t){case"AND":return" && ";case"OR":return" || "}return j(t,"|")||j(t,h)?(" "+t+h).replace(O,function(t){return o.blank(t)||t==h?"":J(e,Q(t).split("|"))}):ot(e,t)}function tt(e){return o[e]?v.assert:a[e]?v.util:v.filter}function nt(e){return e.replace(k,_).split(M).reduce($,[])}function rt(t,n){switch(typeof t){case"boolean":case"number":case"string":return String(t);default:switch(e.ntype(t)){case"date":return t.toDateString();case"array":return z(t,rt).join(", ");case"object":return f in t?rt(t.dict):(n=t.toString())!="[object Object]"?n:z(Object.values(t),rt).join(", ");default:switch(e.type(t)){case"htmlelement":return t.outerHTML;case"htmlcollection":return z(Array.coerce(t),function(e){return rt(e)}).join("\n")}}}return""}function it(e){return this==e||o.startsWith(this,e+".")}function st(e,t){return e.length?e.some(function(e){return e.some(it,t)}):0}function ot(e,t){var n=e.currentIterKeys||[];return t=Q(t),j(t,".call(")||C.test(t)||o.startsWith(t,'"')&&o.endsWith(t,'"')||o.startsWith(t,"'")&&o.endsWith(t,"'")||!isNaN(t)?t:o.startsWith(t,"$_.")||o.startsWith(t,"iter.")||n.length&&st(n,t)||t in i?t.replace(L,A):I('$C.get( "{0}" )',t)}function ut(e){return I("{0} += {1};",v.output,e.replace(E,"\\n"))}function at(){var e=Array.coerce(arguments),t=U(e[e.length-1])?e.pop():U(e[0])?e.shift():null;if(!(this instanceof at))return U(t)?new at(e.join(""),t):new at(e.join(""));!t||c.forEach(function(e){e in t&&(this[e]=t[e],delete t[e])},this),this.filters=t||{},this.__tpl__=e.join(""),D[ft(this)]=this,this.compiled&&(this.compiled=!1,lt(this))}function ft(e){return e.id||(e.id=I(P,++y)),e.id}function lt(e){return e.compiled||(e.compiled=!0,e._parse=Y(e)),e}function ct(e){this.compiled||lt(this),this[v.dict]=e;var t=this._parse(e);return delete this[v.dict],t}function ht(t){function r(e,t,r){!r&&e in n||(n[e]=t)}function i(e,t){switch(typeof t){case"string":r(t,arguments[2],e);break;case"object":for(var n in t)r(n,t[n],e)}return this}var n={};!U(t)||e.copy(n,t),this.all=function(){return e.copy(n)},this.add=function(){return i.call(this,!1,arguments[0],arguments[1])},this.get=function(e){return n[e]},this.replace=function(){return i.call(this,!0,arguments[0],arguments[1])}}var r,i="__ASSERT__ __CONTEXT__ __FILTER_ __OUTPUT__ __UTIL__ $_ document false global instanceof null true typeof undefined window".split(" ").reduce(function(e,t){return e[t]=!0,e},e.obj()),s=/\$?\{([^\}\s]+)\}/g,o={blank:function(t){return e.empty(t)||typeof t=="string"&&!t.trim()},contains:j,endsWith:function(e,t){e=String(e);var n=e.length-t.length;return n>=0&&e.lastIndexOf(t)==n},empty:e.empty,equals:function(e,t){return e==t},exists:e.exists,is:function(e,t){return e===t},isEven:function(e){return!(parseInt(e,10)&1)},isOdd:function(e){return!(parseInt(e,10)&1)},isTPL:function(e){return!!q(I(B,this.id,e))||!!q(e)},iterable:function(t){return e.iter(t)},notEmpty:W,startsWith:function(e,t){return String(e).indexOf(t)===0}},u={},a={inspect:function(t){switch(e.ntype(t)){case"object":case"array":console.dir(t);break;default:console.log(t)}return""},objectify:function(e,t){var n={};return n[t]=e,n},parse:function(e,t,n){var r,i;return t instanceof at?i=t:(t=String(t).trim(),i=q(I(B,this.id,t))||q(t)),i?(e[v.parent]=this[v.dict],r=i.parse(e),delete e[v.parent],r):this.fallback},stop:function(e){e.stop()},stringify:rt,type:function(t,n){var r=e.type(t);return typeof n=="string"?r==n:r},value:function(e,t){return Object.value(e,t)}},f="__tpl_cs_cached_keys",l="__tpl_cs_stack",c="compiled debug dict fallback id".split(" "),h="<~>",p=/([-\*\+\?\.\|\^\$\/\\\(\)[\]\{\}])/g,d="\\$1",v={assert:"__ASSERT__",ctx:"__CONTEXT__",dict:"__dict__",filter:"__FILTER__",output:"__OUTPUT__",parent:"__PARENT__",util:"__UTIL__"},m=I("return {0};\n ",v.output),g='\n"use strict";\n'+I('var $C = new ContextStack( {0}, this.fallback, this.dict ), $_ = $C.current(), iter = new Iter( null ), {1} = "", U;',v.ctx,v.output),y=999,b,w="console",E=/[\n\r]/gm,S=/(['"])/g,x=new RegExp(h,"gm"),T=/[\r\n]+/g,N=/\s+/g,C=/[\(\)\[\]\{\}\?\*\+\/<>%&=!-]/,k,L=/\.(\d+)(\.?)/g,A="['$1']$2",O=new RegExp("\\s*([^\\|]+(?:\\|[^\\|]+?)){0,}"+h,"g"),M="<__SPLIT__TEMPLATE__HERE__>",_=["","$1","$2",""].join(M),D={},P="t8-anon-{0}",H='{0}["{1}"].call( this, {2}{3}, {4} )',B="{0}.{1}";X.prototype={current:function(){return(this.top||this[l][0]).dict},get:function(t){var n,i=this[l],s=i.length,o;while(s--){n=i[s];if(t in n.cache)return n.cache[t];if((o=n.dict[t])!==r||(o=Object.value(n.dict,t))!==r)return n.cache[t]=o}return this.hasFallback?this.fallback:r},pop:function(){var t=this[l].pop().dict;return this.top=this[l][this[l].length-1],t},push:function(n){return this[l].push(this.top={cache:e.obj(),dict:n}),this}},V.prototype={empty:!0,hasNext:function(){return this.stopped||this.empty?!1:(++this.index<this.lastIndex||(this.stop().isLast=!0),this.key=this.keys[this.index1++],this.current=this.val=this._[this.key],this)},stop:function(){return this.stopped=!0,this}},e.defs(V.prototype,{first:{get:function(){return this._[this.keys[this.firstKey]]}},last:{get:function(){return this._[this.keys[this.lastKey]]}},next:{get:function(){return this._[this.keys[this.nextKey]]}},prev:{get:function(){return this._[this.keys[this.prevKey]]}},nextIndex:{get:function(){var e=this.index+1;return e<=this.lastIndex?e:r}},prevIndex:{get:function(){var e=this.index-1;return e>=this.firstIndex?e:r}},firstKey:{get:function(){return this.keys[this.firstIndex]}},lastKey:{get:function(){return this.keys[this.lastIndex]}},nextKey:{get:function(){return this.keys[this.nextIndex]}},prevKey:{get:function(){return this.keys[this.prevIndex]}}},"r"),b={assembleparts:K,clean:Q,compiletpl:G,createtpl:Y,emittag:Z,fnvar:v,formatstatement:et,get:ot,util:a,wrap:ut},at.prototype={compiled:!1,debug:!1,dict:null,fallback:"",parse:ct},e.defs(at,{m8:{value:e},escapeRE:F,format:I,get:q,gsub:R,stringify:rt},"r"),at.Assert=new ht(o),at.Filter=new ht(u),at.Statement=new ht,at.Tag=new function(){function s(t){n.forEach(o,t),e.copy(this,t),i[this.start]=this}function o(e){if(!(e in this))throw new TypeError(I("A "+t+" Tag requires an {0}",r[e]))}var n="emit end start".split(" "),r={emit:"emit function",end:"end tag definition",start:"start tag definition"},i={};this.all=function(){return e.copy(i)},this.compileRegExp=function(){var e=[],t=[],n;for(n in i)e.push(F(i[n].end.substring(0,1))),t.push(F(i[n].start.substring(1)));return k=new RegExp("(\\{["+t.join("")+"])\\s*(.+?)\\s*(["+e.join("")+"]\\})","gm")},this.create=function(e,t){return new s(e),t===!0||this.compileRegExp(),this},this.get=function(e){return i[e]}};var pt=[{start:"{{",end:"}}",emit:function(e,n,r,i){var s,o,u,a;if(r=="")throw new SyntaxError(t+" missing key in value declaration.");!wt.test(r)||(s=j(r,"|")?(r.match(bt)||dt).filter(W):r.match(bt));if(!s||s.length<=2)return e.wrap(e.formatstatement(n,r));s.shift(),a=e.formatstatement(n,s.shift()),u=vt(s.shift().toLowerCase()),o=s.join(" ");if(!u||!o)throw new SyntaxError(t+" missing tag or statement in one liner value declaration.");return u(e,n,o,i)+e.wrap(a)+vt("endif")}},{start:"{%",end:"%}",emit:function(e,n,r,i){if(r=="")throw new SyntaxError(t+" missing key in statement declaration.");var s,o,u;if(!(u=vt(r.toLowerCase()))){s=r.split(" "),u=vt(s.shift().toLowerCase());if(s.length==0&&typeof u=="string")return u;o=s.join(" ");if(!u||!o)throw s=[],u||s.push("tag"),o||s.push("statement"),new SyntaxError(t+" missing "+s.join(" and ")+" in statement declaration.")}if(!u)throw new SyntaxError(I(t+" tag: {0} does not exist.",u));return typeof u=="function"?u(e,n,o,i):u}},{start:"{[",end:"]}",emit:function(e,t,n,r){n=n.replace(mt,"$1").split("for each");var i,s,o,u,a=e.clean(n.shift()),f=e.clean(n.pop()).match(gt);return n=[],f.shift(),u=f.shift(),o=f.shift(),f.length>=2&&(s=f.shift(),i=f.shift()),n.push(vt("for")(e,t,(W(u)?u.match(yt,"$1").join(",")+" in ":"")+o,r)),!i||n.push(vt(s||"if")(e,t,i,r)),n.push(e.wrap(a.split(" ").map(function(n){return e.formatstatement(t,n)}).join(" "))),!i||n.push(vt("endif")),n.push(vt("endfor")(e,t)),n.join("")}},{start:"{:",end:":}",emit:function(e,t,n){return e.formatstatement(t,n)+";"}},{start:"{#",end:"#}",emit:function(e,t,n){return["\n/*",n,"*/\n"].join(" ")}}],dt=[],vt=at.Statement.get,mt=/\s*(,)\s*/g,gt=/^\(\s*(.*?)(?:\bin\b){0,1}(.*?)\s*\)\s*(if|unless){0,1}\s*(.*)$/i,yt=/(\w+)/g,bt=/^(.*?)\s+(if|unless)\s+(.*)|$/i,wt=/\s+(if|unless)\s+/i;pt.forEach(function(e){at.Tag.create(e,!0)}),at.Tag.compileRegExp(),function(){function i(e,t,n){return n.split(" ").map(function(n){return t(e,n)}).join(" ")}var t={"for":function(e,t,i){var s="U",o=s,u,a,f=e.clean(i).match(n),l=s,c=[];return f===null?u=i:(f.shift(),o=f.pop()||s,l=f.pop()||s,u=f.pop()||f.pop(),a=(f.pop()||"").match(r)),u=e.formatstatement(t,u),c.push(I(["","iter = new Iter( {0}, iter, {1}, {2} );","while ( iter.hasNext() ) {","$_ = iter.current;"].join("\n\r"),u,l,o)),a&&a.length>0&&(t.currentIterKeys.unshift(a),a.length<2?c.push(I("var {0} = iter.current;\n\r",a[0])):a.length>=2&&c.push(I("var {0} = iter.key, {1} = iter.current;\n\r",a[0],a[1]))),c.join("")},forempty:"\n\r}\n\rif ( iter.empty ) {\n\r",endfor:function(e,t){return t.currentIterKeys.shift(),I(["\n\r}","iter = iter.parent || new Iter( null );","$_ = iter.current || $C.current(); \n\r"].join("\n\r"),e.fnvar.util)},"if":function(e,t,n){return I("if ( {0} ) { ",i(t,e.formatstatement,n))},elseif:function(e,t,n){return I(" } else if ( {0} ) { ",i(t,e.formatstatement,n))},"else":" } else { ",endif:" }",sub:function(t,n,r,i){var s="endsub",o,u=r.trim(),a,f;return o=i.indexOf([s,u].join(" ")),o>-1||(o=i.indexOf(s)),a=i.splice(0,o+1),a.splice(a.length-2,a.length),u=I("{0}.{1}",n.id,u),f=new at("",e.copy({debug:n.debug,fallback:n.fallback,id:u},n.filters)),f.currentIterKeys=[],f.__tpl__=a.join(""),f._parse=t.compiletpl(f,t.assembleparts(f,a)),delete f.currentIterKeys,f.compiled=!0,""},unless:function(e,t,n){return I("if ( !( {0} ) ) { ",i(t,e.formatstatement,n))}},n=/^(\[[^,]+,\s*[^\]]+\]|[^\s]+)(?:\s+in\s+([^\s\[]+)){0,1}\s*(?:\[?(\d+)\.+(\d*)]*\]?){0,1}/i,r=/(\w+)/g;at.Statement.add(t),at.Statement.add("elsif",t.elseif)}(),at.Filter.add({capitalize:function(e){return e=at.stringify(e),e.charAt(0).toUpperCase()+e.substring(1).toLowerCase()},count:function(t){return e.len(t)||0},crop:function(e,t){return e=at.stringify(e),t=parseInt(t,10)||50,e.length>t?e.substring(0,t/2)+"..."+e.substring(e.length-t/2):e},def:function(e,t){return o.blank(e)?t:e},first:function(t){switch(e.ntype(t)){case"array":return t[0];case"string":return t.charAt(0)}},join:function(t,n){return e.got(t,"join")&&typeof t.join=="function"?t.join(n):t},last:function(t){switch(e.ntype(t)){case"array":return t[t.length-1];case"string":return t.charAt(t.length-1)}},lowercase:function(e){return at.stringify(e).toLowerCase()},prefix:function(e,t){return t+e},suffix:function(e,t){return e+t},truncate:function(e,t){return e=at.stringify(e),t=parseInt(t,10)||50,e.length>t?e.substring(0,t)+"...":e},uppercase:function(e){return at.stringify(e).toUpperCase()},wrap:function(e,t,n){return t+e+(n||t)}}),e.iter(n)||(n=e.ENV=="commonjs"?module:e.global),at=e.expose(at,t,n),e.expose(e,at)}(typeof m8!="undefined"?m8:typeof require!="undefined"?require("m8"):null,"Templ8") |
141252
1662