Comparing version 0.9.26 to 0.10.0
@@ -36,3 +36,3 @@ { | ||
}, | ||
"version" : "0.9.26" | ||
"version" : "0.10.0" | ||
} |
@@ -57,6 +57,7 @@ ( function() { | ||
sub_tpl.currentIterKeys = []; | ||
sub_tpl.__tpl__ = parts.join( '' ); | ||
sub_tpl._parse = internals.compiletpl( sub_tpl, internals.assembleparts( sub_tpl, parts ) ); | ||
sub_tpl.__tpl__ = parts.join( '' ); | ||
sub_tpl._parse = internals.compiletpl( sub_tpl, internals.assembleparts( sub_tpl, parts ) ); | ||
delete sub_tpl.currentIterKeys; | ||
sub_tpl.compiled = true; | ||
sub_tpl.compiled = true; | ||
sub_tpl.parentTemplate = ctx; | ||
@@ -63,0 +64,0 @@ return ''; |
@@ -18,3 +18,3 @@ var U, DEBUG = 'DEBUG', RESERVED = '__ASSERT__ __CONTEXT__ __FILTER_ __OUTPUT__ __UTIL__ $_ document false global instanceof null true typeof undefined window'.split( ' ' ).reduce( function( o, k ) { | ||
isOdd : function( i ) { return !!( parseInt( i, 10 ) & 1 ); }, | ||
isTPL : function( id ) { return !!( getTPL( util.format( tpl_sub, this.id, id ) ) || getTPL( id ) ); }, | ||
isTPL : function( id ) { return !!getTPL( id, this ); }, | ||
iterable : function( o ) { return util.iter( o ); }, | ||
@@ -42,3 +42,3 @@ notEmpty : not_empty, | ||
id = String( id ).trim(); | ||
t = getTPL( util.format( tpl_sub, this.id, id ) ) || getTPL( id ) | ||
t = getTPL( id, this ); | ||
} | ||
@@ -92,4 +92,19 @@ | ||
function getTPL( id ) { return tpl[id] || null; } | ||
function getTPL( id, ref_tpl ) { | ||
if ( !ref_tpl ) | ||
return tpl[id] || null; | ||
var _id; | ||
do { | ||
_id = util.format( tpl_sub, ref_tpl.id, id ); | ||
if ( _id in tpl ) | ||
return tpl[_id]; | ||
} while( ref_tpl = ref_tpl.parentTemplate ); | ||
return tpl[id] || null; | ||
} | ||
function is_obj( o ) { return typeof o == 'object' && ( o.constructor === Object || o.constructor === U ); } | ||
@@ -96,0 +111,0 @@ |
@@ -8,2 +8,3 @@ ;!function( util, Name, PACKAGE ) { | ||
var U, DEBUG = 'DEBUG', RESERVED = '__ASSERT__ __CONTEXT__ __FILTER_ __OUTPUT__ __UTIL__ $_ document false global instanceof null true typeof undefined window'.split( ' ' ).reduce( function( o, k ) { | ||
@@ -26,3 +27,3 @@ o[k] = true; return o; | ||
isOdd : function( i ) { return !!( parseInt( i, 10 ) & 1 ); }, | ||
isTPL : function( id ) { return !!( getTPL( util.format( tpl_sub, this.id, id ) ) || getTPL( id ) ); }, | ||
isTPL : function( id ) { return !!getTPL( id, this ); }, | ||
iterable : function( o ) { return util.iter( o ); }, | ||
@@ -50,3 +51,3 @@ notEmpty : not_empty, | ||
id = String( id ).trim(); | ||
t = getTPL( util.format( tpl_sub, this.id, id ) ) || getTPL( id ) | ||
t = getTPL( id, this ); | ||
} | ||
@@ -100,4 +101,19 @@ | ||
function getTPL( id ) { return tpl[id] || null; } | ||
function getTPL( id, ref_tpl ) { | ||
if ( !ref_tpl ) | ||
return tpl[id] || null; | ||
var _id; | ||
do { | ||
_id = util.format( tpl_sub, ref_tpl.id, id ); | ||
if ( _id in tpl ) | ||
return tpl[_id]; | ||
} while( ref_tpl = ref_tpl.parentTemplate ); | ||
return tpl[id] || null; | ||
} | ||
function is_obj( o ) { return typeof o == 'object' && ( o.constructor === Object || o.constructor === U ); } | ||
@@ -488,4 +504,6 @@ | ||
/*~ src/Tag.js ~*/ | ||
var _tags = [ { | ||
@@ -585,4 +603,6 @@ start : '{{', end : '}}', | ||
/*~ src/Statement.js ~*/ | ||
( function() { | ||
@@ -644,6 +664,7 @@ var _statements = { | ||
sub_tpl.currentIterKeys = []; | ||
sub_tpl.__tpl__ = parts.join( '' ); | ||
sub_tpl._parse = internals.compiletpl( sub_tpl, internals.assembleparts( sub_tpl, parts ) ); | ||
sub_tpl.__tpl__ = parts.join( '' ); | ||
sub_tpl._parse = internals.compiletpl( sub_tpl, internals.assembleparts( sub_tpl, parts ) ); | ||
delete sub_tpl.currentIterKeys; | ||
sub_tpl.compiled = true; | ||
sub_tpl.compiled = true; | ||
sub_tpl.parentTemplate = ctx; | ||
@@ -672,4 +693,6 @@ return ''; | ||
/*~ src/Filter.js ~*/ | ||
__Class__.Filter.add( { | ||
@@ -714,2 +737,3 @@ capitalize : function( str ) { | ||
util.iter( PACKAGE ) || ( PACKAGE = util.ENV == 'commonjs' ? module : util.global ); | ||
@@ -716,0 +740,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t,e,n){"use strict";function r(e,n){return e&&"function"==typeof e.indexOf&&!!~e.indexOf(n)||t.got(e,n)}function i(t){return(t+"").replace(G,H)}function s(t){return ae[t]||null}function u(t){return"object"==typeof t&&(t.constructor===Object||t.constructor===N)}function a(e,n,r){n||(n=t),r||(r=e);for(var i,s=-1,u=e.length,a=[];u>++s;)switch(i=n.call(r,e[s],s,e)){case null:case N:break;default:switch(typeof i){case"string":""===i.trim()||a.push(i);break;case"number":isNaN(i)||a.push(i);break;default:!t.iter(i)||t.len(i)||a.push(i)}}return a}function o(e){return!t.empty(e)}function c(e,n){switch(this[P]=[],this.tpl=n,this.push(t.global),n.fallback!==N&&(this.hasFallback=!0,this.fallback=n.fallback),t.ntype(e)){case"object":this.push(e);break;case"array":e[M.dict]?e.map(this.push,this):this.push(e);break;default:!t.exists(e)||this.push(e)}}function f(e,n,r,i){var s=Object.keys(e=this._=Object(e)),u=s.length;return u?("[object Object]"==t.tostr(e)||(s=s.map(Number)),this.empty=!1,this.count=isNaN(i)?u:0>i?u+i:i>u?u:i,0==r||isNaN(r)?(this.firstIndex=0,this.index=-1):(this.firstIndex=r,this.index=r-2),this.index1=this.index+1,this.lastIndex=this.count===u?this.count-1:this.count,this.keys=s,!(n instanceof f)||(this.parent=n),void 0):this.stop()}function h(e,n){return t.empty(n)||e.push(n),e}function l(e,n){return n.reduce(function(n,r,i){if(0==i)return k(e,r);var s,u="",a=r.indexOf(":");return~a?(s=r.substring(0,a),u=r.substring(a+1)):s=r,!u||(u=", "+u.split(",").map(function(t){return k(this,t)},e).join(", ")),t.format(le,b(s),s,k(e,n),u,M.ctx)},"")}function p(t,e){for(var n,r=[X];n=e.shift();)r.push(y(t,n,e));return r.push(V),r.join("\r\n")}function d(t){return t.replace(Y,"").replace(Z,"\n").replace(te," ").trim()}function m(e,n){n=t.format(oe,"*",e.__tpl__.replace(Q,"$1 \\$2"),n,e.sourceURL?e.sourceURL:t.format(he,e.id));var r=Function("root","ContextStack","Iter",M.filter,M.assert,M.util,M.ctx,n);return r.bind(e,t.global,c,f,t.copy(e.filters,E.Filter.all(),!0),K,F)}function g(t){t.currentIterKeys=[];var e=m(t,p(t,x(t.__tpl__)));return delete t.currentIterKeys,e}function y(e,n,r){var i;return(i=E.Tag.get(n))?(n=r.shift(),i.emit(R,e,n,r)):I(t.format('"{0}"',n.replace(J,"\\$1")))}function _(t,e){switch(e=d(e)){case"AND":return" && ";case"OR":return" || "}return r(e,"|")||r(e,D)?(" "+e+D).replace(ie,function(e){return K.blank(e)||e==D?"":l(t,d(e).split("|"))}):k(t,e)}function b(t){return K[t]?M.assert:F[t]?M.util:M.filter}function x(t){return t.replace(L,ue).split(se).reduce(h,[])}function w(e,n){switch(typeof e){case"boolean":case"number":case"string":return e+"";default:switch(t.ntype(e)){case"date":return e.toDateString();case"array":return a(e,w).join(", ");case"object":return W in e?w(e.dict):"[object Object]"!=(n=""+e)?n:a(Object.values(e),w).join(", ");default:switch(t.type(e)){case"htmlelement":return e.outerHTML;case"htmlcollection":return a(Array.coerce(e),function(t){return w(t)}).join("\n")}}}return""}function v(t){return this==t||K.startsWith(this,t+".")}function j(t,e){return t.length?t.some(function(t){return t.some(v,e)}):0}function k(e,n){var i=e.currentIterKeys||[];return n=d(n),r(n,".call(")||ee.test(n)||K.startsWith(n,'"')&&K.endsWith(n,'"')||K.startsWith(n,"'")&&K.endsWith(n,"'")||!isNaN(n)?n:K.startsWith(n,"$_.")||K.startsWith(n,"iter.")||i.length&&j(i,n)||n in C?n.replace(ne,re):t.format('$C.get( "{0}" )',n)}function I(e){return t.format("{0} += {1};",M.output,e.replace(B,"\\n"))}function E(){var t,e=Array.coerce(arguments),n=u(e[e.length-1])?e.pop():u(e[0])?e.shift():null;return this instanceof E?(!n||q.forEach(function(t){t in n&&(this[t]=n[t],delete n[t])},this),t=this.fallback,(!t&&this.debug||"string"==typeof t&&t.toUpperCase()===U)&&(this.fallback=U),this.filters=n||{},this.__tpl__=e.join("\n"),ae[T(this)]=this,this.compiled&&(this.compiled=!1,S(this)),void 0):u(n)?new E(e.join(""),n):new E(e.join(""))}function T(e){return e.id||(e.id=t.format(fe,++z)),e.id}function O(t){this.compiled||S(this),this[M.dict]=t;var e=this._parse(t);return delete this[M.dict],e}function S(t){return t.compiled||(t.compiled=!0,t._parse=g(t)),t}function $(e){function n(t,e,n){!n&&t in i||(i[t]=e)}function r(t,e){switch(typeof e){case"string":n(e,arguments[2],t);break;case"object":for(var r in e)n(r,e[r],t)}return this}var i={};!u(e)||t.copy(i,e),this.all=function(){return t.copy(i)},this.add=function(){return r.call(this,!1,arguments[0],arguments[1])},this.get=function(t){return i[t]},this.replace=function(){return r.call(this,!0,arguments[0],arguments[1])}}var N,R,L,U="DEBUG",C="__ASSERT__ __CONTEXT__ __FILTER_ __OUTPUT__ __UTIL__ $_ document false global instanceof null true typeof undefined window".split(" ").reduce(function(t,e){return t[e]=!0,t},t.obj()),K={blank:function(e){return t.empty(e)||"string"==typeof e&&!e.trim()},contains:r,endsWith:function(t,e){t+="";var n=t.length-e.length;return n>=0&&t.lastIndexOf(e)==n},empty:t.empty,equals:function(t,e){return t==e},exists:t.exists,is:function(t,e){return t===e},isEven:function(t){return!(1&parseInt(t,10))},isOdd:function(t){return!!(1&parseInt(t,10))},isTPL:function(e){return!(!s(t.format(pe,this.id,e))&&!s(e))},iterable:function(e){return t.iter(e)},notEmpty:o,startsWith:function(t,e){return 0===(t+"").indexOf(e)}},A={},F={inspect:function(e){switch(t.ntype(e)){case"object":case"array":console.dir(e);break;default:console.log(e)}return""},objectify:function(t,e){var n={};return n[e]=t,n},parse:function(e,n){var r,i;return e=Object(e),n instanceof E?i=n:(n=(n+"").trim(),i=s(t.format(pe,this.id,n))||s(n)),i?(e[M.parent]=this[M.dict],r=i.parse(e),delete e[M.parent],r):this.fallback},stop:function(t){t.stop()},stringify:w,type:function(e,n){var r=t.type(e);return"string"==typeof n?r==n:r},value:function(t,e){return Object.value(t,e)}},W="__tpl_cs_cached_keys",P="__tpl_cs_stack",q="compiled debug dict fallback id sourceURL".split(" "),D="<~>",G=/([-\*\+\?\.\|\^\$\/\\\(\)[\]\{\}])/g,H="\\$1",M={assert:"__ASSERT__",ctx:"__CONTEXT__",dict:"__dict__",filter:"__FILTER__",output:"__OUTPUT__",parent:"__PARENT__",util:"__UTIL__"},V=t.format("return {0};\n ",M.output),X='\n"use strict";\n'+t.format('var $C = new ContextStack( {0}, this ), $_ = $C.current(), iter = new Iter( null ), {1} = "", U;',M.ctx,M.output),z=999,B=/[\n\r]/gm,J=/(['"])/g,Q=/(\*)(\/)/gm,Y=RegExp(D,"gm"),Z=/[\r\n]+/g,te=/\s+/g,ee=/[\(\)\[\]\{\}\?\*\+\/<>%&=!-]/,ne=/\.(\d+)(\.?)/g,re="['$1']$2",ie=RegExp("\\s*([^\\|]+(?:\\|[^\\|]+?)){0,}"+D,"g"),se="<__SPLIT__TEMPLATE__HERE__>",ue=["","$1","$2",""].join(se),ae={},oe="/{0}{0} original template string:\n\n{1}\n\n{0}/\n\n// compiled template code: \n\n{2}\n\n//@ sourceURL={3}\n",ce="WARNING: NO VALUE FOUND FOR => {0}",fe="t8-anon-{0}",he="/Templ8/{0}.tpl",le='{0}["{1}"].call( this, {2}{3}, {4} )',pe="{0}.{1}";c.prototype={current:function(){return(this.top||this[P][0]).dict},get:function(e){for(var n,r,i=this.fallback,s=this[P],u=s.length;u--;){if(n=s[u],e in n.cache)return n.cache[e];if((r=n.dict[e])!==N||(r=Object.value(n.dict,e))!==N)return n.cache[e]=r}if(this.hasFallback)switch(t.ntype(i)){case"string":return i===U?t.format(ce,e):i;case"function":return i(e,n.dict)}return N},pop:function(){var t=this[P].pop().dict;return this.top=this[P][this[P].length-1],t},push:function(e){return this[P].push(this.top={cache:t.obj(),dict:e}),this}},f.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}},t.defs(f.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 t=this.index+1;return this.lastIndex>=t?t:N}},prevIndex:{get:function(){var t=this.index-1;return t>=this.firstIndex?t:N}},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"),R={assembleparts:p,clean:d,compiletpl:m,createtpl:g,emittag:y,fnvar:M,formatstatement:_,get:k,util:F,wrap:I},E.prototype={compiled:!1,debug:!1,dict:null,fallback:"",parse:O},t.defs(E,{m8:{value:t},escapeRE:i,format:t.format,get:s,gsub:t.gsub,stringify:w},"r"),E.Assert=new $(K),E.Filter=new $(A),E.Statement=new $,E.Tag=new function(){function n(e){s.forEach(r,e),t.copy(this,e),a[this.start]=this}function r(n){if(!(n in this))throw new TypeError(t.format("A "+e+" Tag requires an {0}",u[n]))}var s="emit end start".split(" "),u={emit:"emit function",end:"end tag definition",start:"start tag definition"},a={};this.all=function(){return t.copy(a)},this.compileRegExp=function(){var t,e=[],n=[];for(t in a)e.push(i(a[t].end.substring(0,1))),n.push(i(a[t].start.substring(1)));return L=RegExp("(\\{["+n.join("")+"])\\s*(.+?)\\s*(["+e.join("")+"]\\})","gm")},this.create=function(t,e){return new n(t),e===!0||this.compileRegExp(),this},this.get=function(t){return a[t]}};var de=[{start:"{{",end:"}}",emit:function(t,n,i,s){var u,a,c,f;if(""==i)throw new SyntaxError(e+" missing key in value declaration.");if(!we.test(i)||(u=r(i,"|")?(i.match(xe)||me).filter(o):i.match(xe)),!u||2>=u.length)return t.wrap(t.formatstatement(n,i));if(u.shift(),f=t.formatstatement(n,u.shift()),c=ge(u.shift().toLowerCase()),a=u.join(" "),!c||!a)throw new SyntaxError(e+" missing tag or statement in one liner value declaration.");return c(t,n,a,s)+t.wrap(f)+ge("endif")}},{start:"{%",end:"%}",emit:function(n,r,i,s){if(""==i)throw new SyntaxError(e+" missing key in statement declaration.");var u,a,o;if(!(o=ge(i.toLowerCase()))){if(u=i.split(" "),o=ge(u.shift().toLowerCase()),0==u.length&&"string"==typeof o)return o;if(a=u.join(" "),!o||!a)throw u=[],o||u.push("tag"),a||u.push("statement"),new SyntaxError(e+" missing "+u.join(" and ")+" in statement declaration.")}if(!o)throw new SyntaxError(t.format(e+" tag: {0} does not exist.",o));return"function"==typeof o?o(n,r,a,s):o}},{start:"{[",end:"]}",emit:function(t,e,n,r){n=n.replace(ye,"$1").split("for each");var i,s,u,a,c=t.clean(n.shift()),f=t.clean(n.pop()).match(_e);return n=[],f.shift(),a=f.shift(),u=f.shift(),f.length>=2&&(s=f.shift(),i=f.shift()),n.push(ge("for")(t,e,(o(a)?a.match(be,"$1").join(",")+" in ":"")+u,r)),!i||n.push(ge(s||"if")(t,e,i,r)),n.push(t.wrap(c.split(" ").map(function(n){return t.formatstatement(e,n)}).join(" "))),!i||n.push(ge("endif")),n.push(ge("endfor")(t,e)),n.join("")}},{start:"{:",end:":}",emit:function(t,e,n){return t.formatstatement(e,n)+";"}},{start:"{#",end:"#}",emit:function(t,e,n){return["\n/*",n,"*/\n"].join(" ")}}],me=[],ge=E.Statement.get,ye=/\s*(,)\s*/g,_e=/^\(\s*(.*?)(?:\bin\b){0,1}(.*?)\s*\)\s*(if|unless){0,1}\s*(.*)$/i,be=/(\w+)/g,xe=/^(.*?)\s+(if|unless)\s+(.*)|$/i,we=/\s+(if|unless)\s+/i;de.forEach(function(t){E.Tag.create(t,!0)}),E.Tag.compileRegExp(),function(){function e(t,e,n){return n.split(" ").map(function(n){return e(t,n)}).join(" ")}var n={"for":function(e,n,s){var u,a,o="U",c=o,f=e.clean(s).match(r),h=o,l=[];return null===f?u=s:(f.shift(),c=f.pop()||o,h=f.pop()||o,u=f.pop()||f.pop(),a=(f.pop()||"").match(i)),u=e.formatstatement(n,u),l.push(t.format(["","iter = new Iter( {0}, iter, {1}, {2} );","while ( iter.hasNext() ) {","$_ = iter.current;"].join("\n\r"),u,h,c)),a&&a.length>0&&(n.currentIterKeys.unshift(a),2>a.length?l.push(t.format("var {0} = iter.current;\n\r",a[0])):a.length>=2&&l.push(t.format("var {0} = iter.key, {1} = iter.current;\n\r",a[0],a[1]))),l.join("")},forempty:"\n\r}\n\rif ( iter.empty ) {\n\r",endfor:function(e,n){return n.currentIterKeys.shift(),t.format(["\n\r}","iter = iter.parent || new Iter( null );","$_ = iter.current || $C.current(); \n\r"].join("\n\r"),e.fnvar.util)},"if":function(n,r,i){return t.format("if ( {0} ) { ",e(r,n.formatstatement,i))},elseif:function(n,r,i){return t.format(" } else if ( {0} ) { ",e(r,n.formatstatement,i))},"else":" } else { ",endif:" }",sub:function(e,n,r,i){var s,u,a,o="endsub",c=r.trim();return s=i.indexOf([o,c].join(" ")),s>-1||(s=i.indexOf(o)),u=i.splice(0,s+1),u.splice(u.length-2,u.length),c=t.format("{0}.{1}",n.id,c),a=new E("",t.copy({debug:n.debug,fallback:n.fallback,id:c},n.filters)),a.currentIterKeys=[],a.__tpl__=u.join(""),a._parse=e.compiletpl(a,e.assembleparts(a,u)),delete a.currentIterKeys,a.compiled=!0,""},unless:function(n,r,i){return t.format("if ( !( {0} ) ) { ",e(r,n.formatstatement,i))}},r=/^(\[[^,]+,\s*[^\]]+\]|[^\s]+)(?:\s+in\s+([^\s\[]+)){0,1}\s*(?:\[?(\d+)\.+(\d*)]*\]?){0,1}/i,i=/(\w+)/g;E.Statement.add(n),E.Statement.add("elsif",n.elseif),E.Statement.add("endunless",n.endif),E.Statement.add("/if",n.endif),E.Statement.add("/unless",n.endif),E.Statement.add("/for",n.endfor),E.Statement.add("/sub",n.endsub)}(),E.Filter.add({capitalize:function(t){return t=E.stringify(t),t.charAt(0).toUpperCase()+t.substring(1).toLowerCase()},count:function(e){return t.len(e)||0},crop:function(t,e){return t=E.stringify(t),e=parseInt(e,10)||50,t.length>e?t.substring(0,e/2)+"..."+t.substring(t.length-e/2):t},def:function(t,e){return K.blank(t)?e:t},first:function(e){switch(t.ntype(e)){case"array":return e[0];case"string":return e.charAt(0)}},join:function(e,n){return t.got(e,"join")&&"function"==typeof e.join?e.join(n):e},last:function(e){switch(t.ntype(e)){case"array":return e[e.length-1];case"string":return e.charAt(e.length-1)}},lowercase:function(t){return E.stringify(t).toLowerCase()},prefix:function(t,e){return e+t},suffix:function(t,e){return t+e},truncate:function(t,e){return t=E.stringify(t),e=parseInt(e,10)||50,t.length>e?t.substring(0,e)+"...":t},uppercase:function(t){return E.stringify(t).toUpperCase()},wrap:function(t,e,n){return e+t+(n||e)}}),t.iter(n)||(n="commonjs"==t.ENV?module:t.global),E=t.expose(E,e,n),t.expose(t,E)}("undefined"!=typeof m8?m8:"undefined"!=typeof require?require("m8"):null,"Templ8"); | ||
!function(t,e,n){"use strict";function r(e,n){return e&&"function"==typeof e.indexOf&&!!~e.indexOf(n)||t.got(e,n)}function i(t){return(t+"").replace(G,H)}function s(e,n){if(!n)return ae[e]||null;var r;do if(r=t.format(pe,n.id,e),r in ae)return ae[r];while(n=n.parentTemplate);return ae[e]||null}function u(t){return"object"==typeof t&&(t.constructor===Object||t.constructor===N)}function a(e,n,r){n||(n=t),r||(r=e);for(var i,s=-1,u=e.length,a=[];u>++s;)switch(i=n.call(r,e[s],s,e)){case null:case N:break;default:switch(typeof i){case"string":""===i.trim()||a.push(i);break;case"number":isNaN(i)||a.push(i);break;default:!t.iter(i)||t.len(i)||a.push(i)}}return a}function o(e){return!t.empty(e)}function c(e,n){switch(this[P]=[],this.tpl=n,this.push(t.global),n.fallback!==N&&(this.hasFallback=!0,this.fallback=n.fallback),t.ntype(e)){case"object":this.push(e);break;case"array":e[M.dict]?e.map(this.push,this):this.push(e);break;default:!t.exists(e)||this.push(e)}}function f(e,n,r,i){var s=Object.keys(e=this._=Object(e)),u=s.length;return u?("[object Object]"==t.tostr(e)||(s=s.map(Number)),this.empty=!1,this.count=isNaN(i)?u:0>i?u+i:i>u?u:i,0==r||isNaN(r)?(this.firstIndex=0,this.index=-1):(this.firstIndex=r,this.index=r-2),this.index1=this.index+1,this.lastIndex=this.count===u?this.count-1:this.count,this.keys=s,!(n instanceof f)||(this.parent=n),void 0):this.stop()}function h(e,n){return t.empty(n)||e.push(n),e}function l(e,n){return n.reduce(function(n,r,i){if(0==i)return k(e,r);var s,u="",a=r.indexOf(":");return~a?(s=r.substring(0,a),u=r.substring(a+1)):s=r,!u||(u=", "+u.split(",").map(function(t){return k(this,t)},e).join(", ")),t.format(le,b(s),s,k(e,n),u,M.ctx)},"")}function p(t,e){for(var n,r=[X];n=e.shift();)r.push(y(t,n,e));return r.push(V),r.join("\r\n")}function d(t){return t.replace(Y,"").replace(Z,"\n").replace(te," ").trim()}function m(e,n){n=t.format(oe,"*",e.__tpl__.replace(Q,"$1 \\$2"),n,e.sourceURL?e.sourceURL:t.format(he,e.id));var r=Function("root","ContextStack","Iter",M.filter,M.assert,M.util,M.ctx,n);return r.bind(e,t.global,c,f,t.copy(e.filters,E.Filter.all(),!0),K,F)}function g(t){t.currentIterKeys=[];var e=m(t,p(t,x(t.__tpl__)));return delete t.currentIterKeys,e}function y(e,n,r){var i;return(i=E.Tag.get(n))?(n=r.shift(),i.emit(R,e,n,r)):I(t.format('"{0}"',n.replace(J,"\\$1")))}function _(t,e){switch(e=d(e)){case"AND":return" && ";case"OR":return" || "}return r(e,"|")||r(e,D)?(" "+e+D).replace(ie,function(e){return K.blank(e)||e==D?"":l(t,d(e).split("|"))}):k(t,e)}function b(t){return K[t]?M.assert:F[t]?M.util:M.filter}function x(t){return t.replace(L,ue).split(se).reduce(h,[])}function w(e,n){switch(typeof e){case"boolean":case"number":case"string":return e+"";default:switch(t.ntype(e)){case"date":return e.toDateString();case"array":return a(e,w).join(", ");case"object":return W in e?w(e.dict):"[object Object]"!=(n=""+e)?n:a(Object.values(e),w).join(", ");default:switch(t.type(e)){case"htmlelement":return e.outerHTML;case"htmlcollection":return a(Array.coerce(e),function(t){return w(t)}).join("\n")}}}return""}function v(t){return this==t||K.startsWith(this,t+".")}function j(t,e){return t.length?t.some(function(t){return t.some(v,e)}):0}function k(e,n){var i=e.currentIterKeys||[];return n=d(n),r(n,".call(")||ee.test(n)||K.startsWith(n,'"')&&K.endsWith(n,'"')||K.startsWith(n,"'")&&K.endsWith(n,"'")||!isNaN(n)?n:K.startsWith(n,"$_.")||K.startsWith(n,"iter.")||i.length&&j(i,n)||n in C?n.replace(ne,re):t.format('$C.get( "{0}" )',n)}function I(e){return t.format("{0} += {1};",M.output,e.replace(B,"\\n"))}function E(){var t,e=Array.coerce(arguments),n=u(e[e.length-1])?e.pop():u(e[0])?e.shift():null;return this instanceof E?(!n||q.forEach(function(t){t in n&&(this[t]=n[t],delete n[t])},this),t=this.fallback,(!t&&this.debug||"string"==typeof t&&t.toUpperCase()===U)&&(this.fallback=U),this.filters=n||{},this.__tpl__=e.join("\n"),ae[T(this)]=this,this.compiled&&(this.compiled=!1,S(this)),void 0):u(n)?new E(e.join(""),n):new E(e.join(""))}function T(e){return e.id||(e.id=t.format(fe,++z)),e.id}function O(t){this.compiled||S(this),this[M.dict]=t;var e=this._parse(t);return delete this[M.dict],e}function S(t){return t.compiled||(t.compiled=!0,t._parse=g(t)),t}function $(e){function n(t,e,n){!n&&t in i||(i[t]=e)}function r(t,e){switch(typeof e){case"string":n(e,arguments[2],t);break;case"object":for(var r in e)n(r,e[r],t)}return this}var i={};!u(e)||t.copy(i,e),this.all=function(){return t.copy(i)},this.add=function(){return r.call(this,!1,arguments[0],arguments[1])},this.get=function(t){return i[t]},this.replace=function(){return r.call(this,!0,arguments[0],arguments[1])}}var N,R,L,U="DEBUG",C="__ASSERT__ __CONTEXT__ __FILTER_ __OUTPUT__ __UTIL__ $_ document false global instanceof null true typeof undefined window".split(" ").reduce(function(t,e){return t[e]=!0,t},t.obj()),K={blank:function(e){return t.empty(e)||"string"==typeof e&&!e.trim()},contains:r,endsWith:function(t,e){t+="";var n=t.length-e.length;return n>=0&&t.lastIndexOf(e)==n},empty:t.empty,equals:function(t,e){return t==e},exists:t.exists,is:function(t,e){return t===e},isEven:function(t){return!(1&parseInt(t,10))},isOdd:function(t){return!!(1&parseInt(t,10))},isTPL:function(t){return!!s(t,this)},iterable:function(e){return t.iter(e)},notEmpty:o,startsWith:function(t,e){return 0===(t+"").indexOf(e)}},A={},F={inspect:function(e){switch(t.ntype(e)){case"object":case"array":console.dir(e);break;default:console.log(e)}return""},objectify:function(t,e){var n={};return n[e]=t,n},parse:function(t,e){var n,r;return t=Object(t),e instanceof E?r=e:(e=(e+"").trim(),r=s(e,this)),r?(t[M.parent]=this[M.dict],n=r.parse(t),delete t[M.parent],n):this.fallback},stop:function(t){t.stop()},stringify:w,type:function(e,n){var r=t.type(e);return"string"==typeof n?r==n:r},value:function(t,e){return Object.value(t,e)}},W="__tpl_cs_cached_keys",P="__tpl_cs_stack",q="compiled debug dict fallback id sourceURL".split(" "),D="<~>",G=/([-\*\+\?\.\|\^\$\/\\\(\)[\]\{\}])/g,H="\\$1",M={assert:"__ASSERT__",ctx:"__CONTEXT__",dict:"__dict__",filter:"__FILTER__",output:"__OUTPUT__",parent:"__PARENT__",util:"__UTIL__"},V=t.format("return {0};\n ",M.output),X='\n"use strict";\n'+t.format('var $C = new ContextStack( {0}, this ), $_ = $C.current(), iter = new Iter( null ), {1} = "", U;',M.ctx,M.output),z=999,B=/[\n\r]/gm,J=/(['"])/g,Q=/(\*)(\/)/gm,Y=RegExp(D,"gm"),Z=/[\r\n]+/g,te=/\s+/g,ee=/[\(\)\[\]\{\}\?\*\+\/<>%&=!-]/,ne=/\.(\d+)(\.?)/g,re="['$1']$2",ie=RegExp("\\s*([^\\|]+(?:\\|[^\\|]+?)){0,}"+D,"g"),se="<__SPLIT__TEMPLATE__HERE__>",ue=["","$1","$2",""].join(se),ae={},oe="/{0}{0} original template string:\n\n{1}\n\n{0}/\n\n// compiled template code: \n\n{2}\n\n//@ sourceURL={3}\n",ce="WARNING: NO VALUE FOUND FOR => {0}",fe="t8-anon-{0}",he="/Templ8/{0}.tpl",le='{0}["{1}"].call( this, {2}{3}, {4} )',pe="{0}.{1}";c.prototype={current:function(){return(this.top||this[P][0]).dict},get:function(e){for(var n,r,i=this.fallback,s=this[P],u=s.length;u--;){if(n=s[u],e in n.cache)return n.cache[e];if((r=n.dict[e])!==N||(r=Object.value(n.dict,e))!==N)return n.cache[e]=r}if(this.hasFallback)switch(t.ntype(i)){case"string":return i===U?t.format(ce,e):i;case"function":return i(e,n.dict)}return N},pop:function(){var t=this[P].pop().dict;return this.top=this[P][this[P].length-1],t},push:function(e){return this[P].push(this.top={cache:t.obj(),dict:e}),this}},f.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}},t.defs(f.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 t=this.index+1;return this.lastIndex>=t?t:N}},prevIndex:{get:function(){var t=this.index-1;return t>=this.firstIndex?t:N}},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"),R={assembleparts:p,clean:d,compiletpl:m,createtpl:g,emittag:y,fnvar:M,formatstatement:_,get:k,util:F,wrap:I},E.prototype={compiled:!1,debug:!1,dict:null,fallback:"",parse:O},t.defs(E,{m8:{value:t},escapeRE:i,format:t.format,get:s,gsub:t.gsub,stringify:w},"r"),E.Assert=new $(K),E.Filter=new $(A),E.Statement=new $,E.Tag=new function(){function n(e){s.forEach(r,e),t.copy(this,e),a[this.start]=this}function r(n){if(!(n in this))throw new TypeError(t.format("A "+e+" Tag requires an {0}",u[n]))}var s="emit end start".split(" "),u={emit:"emit function",end:"end tag definition",start:"start tag definition"},a={};this.all=function(){return t.copy(a)},this.compileRegExp=function(){var t,e=[],n=[];for(t in a)e.push(i(a[t].end.substring(0,1))),n.push(i(a[t].start.substring(1)));return L=RegExp("(\\{["+n.join("")+"])\\s*(.+?)\\s*(["+e.join("")+"]\\})","gm")},this.create=function(t,e){return new n(t),e===!0||this.compileRegExp(),this},this.get=function(t){return a[t]}};var de=[{start:"{{",end:"}}",emit:function(t,n,i,s){var u,a,c,f;if(""==i)throw new SyntaxError(e+" missing key in value declaration.");if(!we.test(i)||(u=r(i,"|")?(i.match(xe)||me).filter(o):i.match(xe)),!u||2>=u.length)return t.wrap(t.formatstatement(n,i));if(u.shift(),f=t.formatstatement(n,u.shift()),c=ge(u.shift().toLowerCase()),a=u.join(" "),!c||!a)throw new SyntaxError(e+" missing tag or statement in one liner value declaration.");return c(t,n,a,s)+t.wrap(f)+ge("endif")}},{start:"{%",end:"%}",emit:function(n,r,i,s){if(""==i)throw new SyntaxError(e+" missing key in statement declaration.");var u,a,o;if(!(o=ge(i.toLowerCase()))){if(u=i.split(" "),o=ge(u.shift().toLowerCase()),0==u.length&&"string"==typeof o)return o;if(a=u.join(" "),!o||!a)throw u=[],o||u.push("tag"),a||u.push("statement"),new SyntaxError(e+" missing "+u.join(" and ")+" in statement declaration.")}if(!o)throw new SyntaxError(t.format(e+" tag: {0} does not exist.",o));return"function"==typeof o?o(n,r,a,s):o}},{start:"{[",end:"]}",emit:function(t,e,n,r){n=n.replace(ye,"$1").split("for each");var i,s,u,a,c=t.clean(n.shift()),f=t.clean(n.pop()).match(_e);return n=[],f.shift(),a=f.shift(),u=f.shift(),f.length>=2&&(s=f.shift(),i=f.shift()),n.push(ge("for")(t,e,(o(a)?a.match(be,"$1").join(",")+" in ":"")+u,r)),!i||n.push(ge(s||"if")(t,e,i,r)),n.push(t.wrap(c.split(" ").map(function(n){return t.formatstatement(e,n)}).join(" "))),!i||n.push(ge("endif")),n.push(ge("endfor")(t,e)),n.join("")}},{start:"{:",end:":}",emit:function(t,e,n){return t.formatstatement(e,n)+";"}},{start:"{#",end:"#}",emit:function(t,e,n){return["\n/*",n,"*/\n"].join(" ")}}],me=[],ge=E.Statement.get,ye=/\s*(,)\s*/g,_e=/^\(\s*(.*?)(?:\bin\b){0,1}(.*?)\s*\)\s*(if|unless){0,1}\s*(.*)$/i,be=/(\w+)/g,xe=/^(.*?)\s+(if|unless)\s+(.*)|$/i,we=/\s+(if|unless)\s+/i;de.forEach(function(t){E.Tag.create(t,!0)}),E.Tag.compileRegExp(),function(){function e(t,e,n){return n.split(" ").map(function(n){return e(t,n)}).join(" ")}var n={"for":function(e,n,s){var u,a,o="U",c=o,f=e.clean(s).match(r),h=o,l=[];return null===f?u=s:(f.shift(),c=f.pop()||o,h=f.pop()||o,u=f.pop()||f.pop(),a=(f.pop()||"").match(i)),u=e.formatstatement(n,u),l.push(t.format(["","iter = new Iter( {0}, iter, {1}, {2} );","while ( iter.hasNext() ) {","$_ = iter.current;"].join("\n\r"),u,h,c)),a&&a.length>0&&(n.currentIterKeys.unshift(a),2>a.length?l.push(t.format("var {0} = iter.current;\n\r",a[0])):a.length>=2&&l.push(t.format("var {0} = iter.key, {1} = iter.current;\n\r",a[0],a[1]))),l.join("")},forempty:"\n\r}\n\rif ( iter.empty ) {\n\r",endfor:function(e,n){return n.currentIterKeys.shift(),t.format(["\n\r}","iter = iter.parent || new Iter( null );","$_ = iter.current || $C.current(); \n\r"].join("\n\r"),e.fnvar.util)},"if":function(n,r,i){return t.format("if ( {0} ) { ",e(r,n.formatstatement,i))},elseif:function(n,r,i){return t.format(" } else if ( {0} ) { ",e(r,n.formatstatement,i))},"else":" } else { ",endif:" }",sub:function(e,n,r,i){var s,u,a,o="endsub",c=r.trim();return s=i.indexOf([o,c].join(" ")),s>-1||(s=i.indexOf(o)),u=i.splice(0,s+1),u.splice(u.length-2,u.length),c=t.format("{0}.{1}",n.id,c),a=new E("",t.copy({debug:n.debug,fallback:n.fallback,id:c},n.filters)),a.currentIterKeys=[],a.__tpl__=u.join(""),a._parse=e.compiletpl(a,e.assembleparts(a,u)),delete a.currentIterKeys,a.compiled=!0,a.parentTemplate=n,""},unless:function(n,r,i){return t.format("if ( !( {0} ) ) { ",e(r,n.formatstatement,i))}},r=/^(\[[^,]+,\s*[^\]]+\]|[^\s]+)(?:\s+in\s+([^\s\[]+)){0,1}\s*(?:\[?(\d+)\.+(\d*)]*\]?){0,1}/i,i=/(\w+)/g;E.Statement.add(n),E.Statement.add("elsif",n.elseif),E.Statement.add("endunless",n.endif),E.Statement.add("/if",n.endif),E.Statement.add("/unless",n.endif),E.Statement.add("/for",n.endfor),E.Statement.add("/sub",n.endsub)}(),E.Filter.add({capitalize:function(t){return t=E.stringify(t),t.charAt(0).toUpperCase()+t.substring(1).toLowerCase()},count:function(e){return t.len(e)||0},crop:function(t,e){return t=E.stringify(t),e=parseInt(e,10)||50,t.length>e?t.substring(0,e/2)+"..."+t.substring(t.length-e/2):t},def:function(t,e){return K.blank(t)?e:t},first:function(e){switch(t.ntype(e)){case"array":return e[0];case"string":return e.charAt(0)}},join:function(e,n){return t.got(e,"join")&&"function"==typeof e.join?e.join(n):e},last:function(e){switch(t.ntype(e)){case"array":return e[e.length-1];case"string":return e.charAt(e.length-1)}},lowercase:function(t){return E.stringify(t).toLowerCase()},prefix:function(t,e){return e+t},suffix:function(t,e){return t+e},truncate:function(t,e){return t=E.stringify(t),e=parseInt(e,10)||50,t.length>e?t.substring(0,e)+"...":t},uppercase:function(t){return E.stringify(t).toUpperCase()},wrap:function(t,e,n){return e+t+(n||e)}}),t.iter(n)||(n="commonjs"==t.ENV?module:t.global),E=t.expose(E,e,n),t.expose(t,E)}("undefined"!=typeof m8?m8:"undefined"!=typeof require?require("m8"):null,"Templ8"); |
146670
1812