Comparing version 7.0.0 to 7.0.2
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Liquid=e()}(this,function(){"use strict";var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function e(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function B(o,s,u,a){return new(u||(u=Promise))(function(t,e){function r(t){try{i(a.next(t))}catch(t){e(t)}}function n(t){try{i(a.throw(t))}catch(t){e(t)}}function i(e){e.done?t(e.value):new u(function(t){t(e.value)}).then(r,n)}i((a=a.apply(o,s||[])).next())})}function U(r,n){var i,o,s,t,u={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;u;)try{if(i=1,o&&(s=2&e[0]?o.return:e[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,e[1])).done)return s;switch(o=0,s&&(e=[2&e[0],s.value]),e[0]){case 0:case 1:s=e;break;case 4:return u.label++,{value:e[1],done:!1};case 5:u.label++,o=e[1],e=[0];continue;case 7:e=u.ops.pop(),u.trys.pop();continue;default:if(!(s=0<(s=u.trys).length&&s[s.length-1])&&(6===e[0]||2===e[0])){u=0;continue}if(3===e[0]&&(!s||e[1]>s[0]&&e[1]<s[3])){u.label=e[1];break}if(6===e[0]&&u.label<s[1]){u.label=s[1],s=e;break}if(s&&u.label<s[2]){u.label=s[2],u.ops.push(e);break}s[2]&&u.ops.pop(),u.trys.pop();continue}e=n.call(r,u)}catch(t){e=[6,t],o=0}finally{i=s=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}var i=Object.prototype.toString,o=Array.prototype.toString;function W(t){return"[object String]"===i.call(t)}function s(t){return"function"==typeof t}function u(t){return a(t)?String(t):s(t.to_liquid)?u(t.to_liquid()):s(t.toLiquid)?u(t.toLiquid()):s(t.to_s)?t.to_s():-1<[i,o].indexOf(t.toString)?(e=t,r=[],JSON.stringify(e,function(t,e){if(X(e)){if(-1!==r.indexOf(e))return;r.push(e)}return e})):s(t.toString)?t.toString():i.call(t);var e,r}function J(t){return Object.create(t)}function a(t){return null==t}function G(t){return"[object Array]"===i.call(t)}function m(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return e=X(e)?e:{},t.forEach(function(t){return function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])}(e,t)}),e}function y(t){return t[t.length-1]}function X(t){var e=typeof t;return null!==t&&("object"===e||"function"===e)}var t=new RegExp(/'[^']*'/.source+"|"+/"[^"]*"/.source),f=new RegExp("(?:"+t.source+"|[^'\"])*"),r=/-?\d+\.?\d*|\.?\d+/,c=/true|false/,K=/[\w-]+[?]?/,l=new RegExp("\\[(?:"+t.source+"|[\\w-\\.]+)\\]"),p=new RegExp("(?:"+t.source+"|"+c.source+"|"+r.source+")"),h=new RegExp(K.source+"(?:\\."+K.source+"|"+l.source+")*"),d=new RegExp("(?:"+h.source+"|"+r.source+")"),g=new RegExp("\\("+d.source+"\\.\\."+d.source+"\\)"),v=new RegExp("\\(("+d.source+")\\.\\.("+d.source+")\\)"),Q=new RegExp("(?:"+h.source+"|"+p.source+"|"+g.source+")"),Z=new RegExp("(?:"+K.source+")\\s*:\\s*(?:"+Q.source+")"),w=new RegExp("("+K.source+")\\s*:\\s*("+Q.source+")","g"),b=new RegExp("^\\s*("+K.source+")\\s*([\\s\\S]*)\\s*$"),x=new RegExp("^"+p.source+"$","i"),T=new RegExp("^"+h.source+"$"),E=new RegExp("^"+r.source+"$"),k=new RegExp("^"+c.source+"$","i"),tt=new RegExp("^"+t.source+"$"),S=new RegExp("^"+v.source+"$"),_=new RegExp("^"+/-?\d+/.source+"$"),R=new RegExp("(?:"+K.source+"\\s*:\\s*)?"+Q.source),M=new RegExp(R.source+"(\\s*,\\s*"+R.source+")*"),O=new RegExp(K.source+"(?:\\s*:\\s*"+M.source+")?","g"),j=new RegExp("("+K.source+")(?:\\s*:\\s*("+M.source+"))?"),A=new RegExp("^"+j.source+"$"),D=[/\s+or\s+/,/\s+and\s+/,/==|!=|<=|>=|<|>|\s+contains\s+/];function q(){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}var C=function(){function t(t,e){this.input=e.input,this.line=e.line,this.file=e.file,this.originalError=t,this.token=e}return t.prototype.captureStackTrace=function(t){this.name=t.constructor.name,q.call(t);var e,s,u,r,a,n=this.originalError,i=(e=this.input,s=this.line,u=e.split("\n"),r=Math.max(s-2,1),a=Math.min(s+3,u.length),function(t,e,r){1===arguments.length&&(e=t,t=0),r=r||1;for(var n=[],i=t;i<e;i+=r)n.push(i);return n}(r,a+1).map(function(t){var e,r,n=t===s?">> ":" ",i=(e=String(a).length,r=t,r=String(r),Array(e-r.length).join(" ")+r),o=u[t-1];return""+n+i+"| "+o}).join("\n"));this.message=function(t,e){t=t||"",e.file&&(t+=", file:"+e.file);e.line&&(t+=", line:"+e.line);return t}(n.message,this.token),this.stack=i+"\n"+(this.stack||this.message)+(n.stack?"\nFrom "+n.stack:"")},t}(),F=function(n){function t(t,e){var r=n.call(this,{message:t},e)||this;return n.prototype.captureStackTrace.call(r,r),r}return e(t,n),t}(C);F.prototype=J(Error.prototype),F.prototype.constructor=F;var P=function(n){function t(t,e){var r=n.call(this,t,e)||this;return m(r,t),n.prototype.captureStackTrace.call(r,r),r}return e(t,n),t}(C);P.prototype=J(Error.prototype),P.prototype.constructor=P;var L=function(n){function t(t,e){var r=n.call(this,t,e.token)||this;return m(r,t),n.prototype.captureStackTrace.call(r,r),r}return e(t,n),t}(C);L.prototype=J(Error.prototype),L.prototype.constructor=L;var I=function(t){q.call(this),this.message=t+""};I.prototype=J(Error.prototype),I.prototype.constructor=I;var V=function(t){q.call(this),this.message=t+""};function et(t,e){if(!t)throw new V(e=e||"expect "+t+" to be true")}V.prototype=J(Error.prototype),V.prototype.constructor=V;var $=function(){function t(t,e){void 0===t&&(t={});this.opts=m({dynamicPartials:!0,strict_variables:!1,strict_filters:!1,blocks:{},root:[]},e),this.contexts=[t||{}]}return t.prototype.getAll=function(){return this.contexts.reduce(function(t,e){return m(t,e)},J(null))},t.prototype.get=function(t){var r=this,e=this.propertyAccessSeq(t),n=this.findContextFor(e[0])||y(this.contexts);return e.reduce(function(t,e){return r.readProperty(t,e)},n)},t.prototype.set=function(t,r){var n=this.propertyAccessSeq(t),i=this.findContextFor(n[0])||y(this.contexts);n.some(function(t,e){return!X(i)||(e===n.length-1?(i[t]=r,!0):(void 0===i[t]&&(i[t]={}),void(i=i[t])))})},t.prototype.unshift=function(t){return this.contexts.unshift(t)},t.prototype.push=function(t){return this.contexts.push(t)},t.prototype.pop=function(e){if(!arguments.length)return this.contexts.pop();var t=this.contexts.findIndex(function(t){return t===e});if(-1===t)throw new TypeError("scope not found, cannot pop");return this.contexts.splice(t,1)[0]},t.prototype.findContextFor=function(t,e){void 0===e&&(e=function(t){return!0});for(var r=this.contexts.length-1;0<=r;r--){var n=this.contexts[r];if(e(n)&&t in n)return n}return null},t.prototype.readProperty=function(t,e){var r,n;if(a(t)?r=void 0:(t=function(t){if(s(t.to_liquid))return t.to_liquid();if(s(t.toLiquid))return t.toLiquid();return t}(t),r="size"===e?a((n=t).size)&&(G(n)||W(n))?n.length:n.size:t[e],s(t.liquid_method_missing)&&(r=t.liquid_method_missing(e))),a(r)&&this.opts.strict_variables)throw new TypeError("undefined variable: "+e);return r},t.prototype.propertyAccessSeq=function(t){t=String(t);for(var e,r,n=[],i="",o=0;o<t.length;)switch(t[o]){case"[":u();var s=t[o+1];o=/['"]/.test(s)?(et(-1!==(e=t.indexOf(s,o+2)),"unbalanced "+s+": "+t),i=t.slice(o+2,e),u(),e+2):(et(-1!==(e=Y(t,o+1)),"unbalanced []: "+t),i=t.slice(o+1,e),r=i,_.test(r)||(i=String(this.get(i))),u(),e+1);break;case".":u(),o++;break;default:i+=t[o],o++}if(u(),!n.length)throw new TypeError('invalid path:"'+t+'"');return n;function u(){i.length&&n.push(i),i=""}},t}();function Y(t,e){for(var r=1,n=e;n<t.length;n++)if("["===t[n]&&r++,"]"===t[n]&&0===--r)return n;return-1}function H(t,e,i){return G(e=e||i.root)&&(e=e[0]),e.length&&"/"!==y(e)&&(e+="/"),function(t,e){var r=document.createElement("base");r.href=t;var n=document.getElementsByTagName("head")[0];n.insertBefore(r,n.firstChild);var i=document.createElement("a");i.href=e;var o=i.href;return n.removeChild(r),o}(e,t).replace(/^(\w+:\/\/[^/]+)(\/[^?]+)/,function(t,e,r){var n=r.split("/").pop();return/\.\w+$/.test(n)?t:e+r+i.extname})}function N(o,s,t){et(W(o),"illegal input");for(var r,n,i,e,u,a,c=/({%-?([\s\S]*?)-?%})|({{-?([\s\S]*?)-?}})/g,l=0,p=(r=o,n=0,i=-1,{get:function(t){var e=r.slice(i+1,t).split("\n");return n+=e.length-1,i=t,n+1}}),f=0,h=[],d=void 0;d=c.exec(o);f=c.lastIndex)d.index>f&&h.push(v(f,d.index)),h.push(d[1]?g(d[1],d[2].trim(),d.index):(e=d[3],u=d[4].trim(),a=d.index,{type:"value",line:p.get(a),trim_left:"{{-"===e.slice(0,3),trim_right:"-}}"===e.slice(-3),raw:e,value:u,input:o,file:s}));return o.length>f&&h.push(v(f,o.length)),function(s,u){u=m({greedy:!0},u);var a=!1;s.forEach(function(t,e){var r,n,i,o;i=t,o=u,!a&&("tag"===i.type?i.trim_left||o.trim_tag_left:"value"===i.type?i.trim_left||o.trim_value_left:void 0)&&function(t,e){if(t&&"html"===t.type){var r=e?/\s+$/g:/[\t\r ]*$/g;t.value=t.value.replace(r,"")}}(s[e-1],u.greedy),"tag"===t.type&&"raw"===t.name&&(a=!0),"tag"===t.type&&"endraw"===t.name&&(a=!1),r=t,n=u,!a&&("tag"===r.type?r.trim_right||n.trim_tag_right:"value"===r.type?r.trim_right||n.trim_value_right:void 0)&&function(t,e){if(t&&"html"===t.type){var r=e?/^\s+/g:/^[\t\r ]*\n?/g;t.value=t.value.replace(r,"")}}(s[e+1],u.greedy)})}(h,t),h;function g(t,e,r){var n=e.match(b),i={type:"tag",indent:l,line:p.get(r),trim_left:"{%-"===t.slice(0,3),trim_right:"-%}"===t.slice(-3),raw:t,value:e,input:o,file:s};if(!n)throw new F("illegal tag syntax",i);return i.name=n[1],i.args=n[2],i}function v(t,e){var r=o.slice(t,e);return l=y(r.split("\n")).length,{type:"html",raw:r,value:r}}}var z,rt=(z=ot,{"==":function(t,e){return t===e},"!=":function(t,e){return t!==e},">":function(t,e){return null!==t&&null!==e&&e<t},"<":function(t,e){return null!==t&&null!==e&&t<e},">=":function(t,e){return null!==t&&null!==e&&e<=t},"<=":function(t,e){return null!==t&&null!==e&&t<=e},contains:function(t,e){return!!t&&"function"==typeof t.indexOf&&-1<t.indexOf(e)},and:function(t,e){return z(t)&&z(e)},or:function(t,e){return z(t)||z(e)}});function nt(t,e){et(e,"unable to evalExp: scope undefined");for(var r,n=D,i=0;i<n.length;i++){var o=n[i],s=new RegExp("^("+f.source+")("+o.source+")("+f.source+")$");if(r=t.match(s)){var u=nt(r[1],e);return(0,rt[r[2].trim()])(u,nt(r[3],e))}}if(r=t.match(S)){for(var a=it(r[1],e),c=it(r[2],e),l=[],p=a;p<=c;p++)l.push(p);return l}return it(t,e)}function it(t,e){if(t=t&&t.trim()){if(r=t,x.test(r))return function(t){var e=t.match(E);if(e)return Number(t);if(e=t.match(k))return"true"===t.toLowerCase();if(e=t.match(tt))return t.slice(1,-1);throw new TypeError("cannot parse '"+t+"' as literal")}(t);var r,n;if(n=t,T.test(n))return e.get(t);throw new TypeError("cannot eval '"+t+"' as value")}}function ot(t){return!st(t)}function st(t){return!1===t||null==t}var ut={renderTemplates:function(u,a){return B(this,void 0,void 0,function(){var e,r,n,i,o,s;return U(this,function(t){switch(t.label){case 0:et(a,"unable to evalTemplates: scope undefined"),e="",r=0,n=u,t.label=1;case 1:if(!(r<n.length))return[3,6];i=n[r],t.label=2;case 2:return t.trys.push([2,4,,5]),o=e,[4,function(r){return B(this,void 0,void 0,function(){var e;return U(this,function(t){switch(t.label){case 0:return"tag"!==r.type?[3,2]:[4,this.renderTag(r,a)];case 1:return[2,void 0===(e=t.sent())?"":e];case 2:return"value"===r.type?[2,this.renderValue(r,a)]:[2,r.value]}})})}.call(this,i)];case 3:return e=o+t.sent(),[3,5];case 4:if((s=t.sent())instanceof I)throw s.resolvedHTML=e,s;throw s instanceof L?s:new L(s,i);case 5:return r++,[3,1];case 6:return[2,e]}})})},renderTag:function(e,r){return B(this,void 0,void 0,function(){return U(this,function(t){if("continue"===e.name)throw new I("continue");if("break"===e.name)throw new I("break");return[2,e.render(r)]})})},renderValue:function(r,n){return B(this,void 0,void 0,function(){var e;return U(this,function(t){return[2,void 0===(e=this.evalValue(r,n))?"":u(e)]})})},evalValue:function(t,r){return et(r,"unable to evalValue: scope undefined"),t.filters.reduce(function(t,e){return e.render(t,r)},nt(t.initial,r))}};function at(){var n={},i={render:function(n){return B(this,void 0,void 0,function(){var e,r;return U(this,function(t){return e=function(t,e){var r,n={};for(w.lastIndex=0;r=w.exec(t);){var i=r[1],o=r[2];n[i]=it(o,e)}return n}(this.token.args,n),"function"!=typeof(r=this.tagImpl).render?[2,""]:[2,r.render(n,e)]})})},parse:function(t,e){this.type="tag",this.token=t,this.name=t.name;var r=n[this.name];et(r,"tag "+this.name+" not found"),this.tagImpl=J(r),this.tagImpl.parse&&this.tagImpl.parse(t,e)}};return{construct:function(t,e){var r=J(i);return r.parse(t,e),r},register:function(t,e){n[t]=e},clear:function(){n={}}}}var ct=new RegExp(""+Q.source,"g");function lt(r,o){var e=function(){function t(t){this.tokens=t,this.handlers={}}return t.prototype.on=function(t,e){return this.handlers[t]=e,this},t.prototype.trigger=function(t,e){var r=this.handlers[t];if("function"==typeof r)return r(e),!0},t.prototype.start=function(){var t;for(this.trigger("start");!this.stopRequested&&(t=this.tokens.shift());)if(!(this.trigger("token",t)||"tag"===t.type&&this.trigger("tag:"+t.name,t))){var e=n(t,this.tokens);this.trigger("template",e)}return this.stopRequested||this.trigger("end"),this},t.prototype.stop=function(){return this.stopRequested=!0,this},t}();function n(e,t){try{var r=null;return(r="tag"===e.type?i(e,t):"value"===e.type?s(e.value):e).token=e,r}catch(t){throw new P(t,e)}}function i(t,e){return"continue"===t.name||"break"===t.name?t:r.construct(t,e)}function s(t){var e,r=(e=t,Q.exec(e));et(r,"illegal value string: "+t);var n=r[0];t=t.substr(r.index+r[0].length);for(var i=[];r=O.exec(t);)i.push([r[0].trim()]);return{type:"value",initial:n,filters:i.map(function(t){return o.construct(t)})}}return{parse:function(t){for(var e,r=[];e=t.shift();)r.push(n(e,t));return r},parseTag:i,parseStream:function(t){return new e(t)},parseValue:s}}function pt(r,n){var i=Promise.resolve("init"),o=[];return r.forEach(function(t,e){i=i.then(function(){return n(t,e,r)}).then(function(t){return o.push(t)})}),i.then(function(){return o})}var ft=/[^\s,]+/;function ht(t,e){var r,n,i,o,s,u,a,c,l,p,f,h,d,g,v,m,y,w,b,x,T,E,k,S,_,R,M,O,j,A,D,q,C,F,P,L,I,V,$,Y,H,N,z;r=t,n=e,i=new RegExp("("+K.source+")\\s*=([^]*)"),o=n.Types.AssignScope,r.registerTag("assign",{parse:function(t){var e=t.args.match(i);et(e,"illegal token "+t.raw),this.key=e[1],this.value=e[2]},render:function(t){var e=J(o);return e[this.key]=r.evalValue(this.value,t),t.push(e),Promise.resolve("")}}),s=t,u=e,a=new RegExp("("+K.source+")"),c=u.Types.CaptureScope,s.registerTag("capture",{parse:function(e,t){var r=this,n=e.args.match(a);et(n,e.args+" not valid identifier"),this.variable=n[1],this.templates=[];var i=s.parser.parseStream(t);i.on("tag:endcapture",function(t){return i.stop()}).on("template",function(t){return r.templates.push(t)}).on("end",function(t){throw new Error("tag "+e.raw+" not closed")}),i.start()},render:function(n,t){return B(this,void 0,void 0,function(){var e,r;return U(this,function(t){switch(t.label){case 0:return[4,s.renderer.renderTemplates(this.templates,n)];case 1:return e=t.sent(),(r=J(c))[this.variable]=e,n.push(r),[2]}})})}}),p=e,(l=t).registerTag("case",{parse:function(e,t){var r=this;this.cond=e.args,this.cases=[],this.elseTemplates=[];var n=[],i=l.parser.parseStream(t).on("tag:when",function(t){r.cases.push({val:t.args,templates:n=[]})}).on("tag:else",function(){return n=r.elseTemplates}).on("tag:endcase",function(t){return i.stop()}).on("template",function(t){return n.push(t)}).on("end",function(t){throw new Error("tag "+e.raw+" not closed")});i.start()},render:function(t,e){for(var r=0;r<this.cases.length;r++){var n=this.cases[r];if(p.evalExp(n.val,t)===p.evalExp(this.cond,t))return l.renderer.renderTemplates(n.templates,t)}return l.renderer.renderTemplates(this.elseTemplates,t)}}),(f=t).registerTag("comment",{parse:function(e,t){var r=f.parser.parseStream(t);r.on("token",function(t){"endcomment"===t.name&&r.stop()}).on("end",function(t){throw new Error("tag "+e.raw+" not closed")}),r.start()}}),h=t,d=e,g=new RegExp("^(?:("+Q.source+")\\s*:\\s*)?(.*)$"),v=new RegExp(Q.source,"g"),h.registerTag("cycle",{parse:function(t,e){var r=g.exec(t.args);et(r,"illegal tag: "+t.raw),this.group=r[1]||"";var n=r[2];for(this.candidates=[];r=v.exec(n);)this.candidates.push(r[0]);et(this.candidates.length,"empty candidates: "+t.raw)},render:function(t,e){var r="cycle:"+d.evalValue(this.group,t)+":"+this.candidates.join(","),n=t.opts.groups=t.opts.groups||{},i=n[r];void 0===i&&(i=n[r]=0);var o=this.candidates[i];return i=(i+1)%this.candidates.length,n[r]=i,d.evalValue(o,t)}}),m=t,y=e.Types,w=y.CaptureScope,b=y.AssignScope,x=y.DecrementScope,m.registerTag("decrement",{parse:function(t){var e=t.args.match(K);et(e,"illegal identifier "+t.args),this.variable=e[0]},render:function(t,e){var r=t.findContextFor(this.variable,function(t){var e=Object.getPrototypeOf(t);return e!==w&&e!==b});return r||(r=J(x),t.unshift(r)),"number"!=typeof r[this.variable]&&(r[this.variable]=0),--r[this.variable]}}),T=t,k=(E=e).Types.RenderBreakError,S=new RegExp("^("+K.source+")\\s+in\\s+("+Q.source+")(?:\\s+"+Z.source+")*(?:\\s+(reversed))?(?:\\s+"+Z.source+")*$"),T.registerTag("for",{parse:function(t,e){var r,n=this,i=S.exec(t.args);et(i,"illegal tag: "+t.raw),this.variable=i[1],this.collection=i[2],this.reversed=!!i[3],this.templates=[],this.elseTemplates=[];var o=T.parser.parseStream(e).on("start",function(){return r=n.templates}).on("tag:else",function(){return r=n.elseTemplates}).on("tag:endfor",function(){return o.stop()}).on("template",function(t){return r.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});o.start()},render:function(a,c){return B(this,void 0,void 0,function(){var n,e,r,i,o,s,u=this;return U(this,function(t){switch(t.label){case 0:return G(n=E.evalExp(this.collection,a))||(W(n)&&0<n.length?n=[n]:X(n)&&(n=Object.keys(n).map(function(t){return[t,n[t]]}))),G(n)&&n.length?(e=c.offset||0,r=void 0===c.limit?n.length:c.limit,n=n.slice(e,e+r),this.reversed&&n.reverse(),i=n.map(function(t,e){var r={};return r[u.variable]=t,r.forloop={first:0===e,index:e+1,index0:e,last:e===n.length-1,length:n.length,rindex:n.length-e,rindex0:n.length-e-1},r}),o="",s=!1,[4,pt(i,function(n){return B(u,void 0,void 0,function(){var e,r;return U(this,function(t){switch(t.label){case 0:if(s)return[2];a.push(n),t.label=1;case 1:return t.trys.push([1,3,,4]),e=o,[4,T.renderer.renderTemplates(this.templates,a)];case 2:return o=e+t.sent(),[3,4];case 3:if(!((r=t.sent())instanceof k))throw r;return o+=r.resolvedHTML,"break"===r.message&&(s=!0),[3,4];case 4:return a.pop(n),[2]}})})})]):[2,T.renderer.renderTemplates(this.elseTemplates,a)];case 1:return t.sent(),[2,o]}})})}}),R=e,(_=t).registerTag("if",{parse:function(e,t){var r,n=this;this.branches=[],this.elseTemplates=[];var i=_.parser.parseStream(t).on("start",function(){return n.branches.push({cond:e.args,templates:r=[]})}).on("tag:elsif",function(t){n.branches.push({cond:t.args,templates:r=[]})}).on("tag:else",function(){return r=n.elseTemplates}).on("tag:endif",function(t){return i.stop()}).on("template",function(t){return r.push(t)}).on("end",function(t){throw new Error("tag "+e.raw+" not closed")});i.start()},render:function(t,e){for(var r=0,n=this.branches;r<n.length;r++){var i=n[r],o=R.evalExp(i.cond,t);if(R.isTruthy(o))return _.renderer.renderTemplates(i.templates,t)}return _.renderer.renderTemplates(this.elseTemplates,t)}}),M=t,O=e,j=new RegExp("with\\s+("+Q.source+")"),M.registerTag("include",{parse:function(t){var e=ft.exec(t.args);e&&(this.staticValue=e[0]),(e=Q.exec(t.args))&&(this.value=e[0]),(e=j.exec(t.args))&&(this.with=e[1])},render:function(u,a){return B(this,void 0,void 0,function(){var e,r,n,i,o,s;return U(this,function(t){switch(t.label){case 0:return u.opts.dynamicPartials?tt.exec(this.value)?(r=this.value.slice(1,-1),[4,M.parseAndRender(r,u.getAll(),u.opts)]):[3,2]:[3,4];case 1:return e=t.sent(),[3,3];case 2:e=O.evalValue(this.value,u),t.label=3;case 3:return[3,5];case 4:e=this.staticValue,t.label=5;case 5:return et(e,"cannot include with empty filename"),n=u.opts.blocks,i=u.opts.blockMode,u.opts.blocks={},u.opts.blockMode="output",this.with&&(a[e]=O.evalValue(this.with,u)),[4,M.getTemplate(e,u.opts.root)];case 6:return o=t.sent(),u.push(a),[4,M.renderer.renderTemplates(o,u)];case 7:return s=t.sent(),u.pop(a),u.opts.blocks=n,u.opts.blockMode=i,[2,s]}})})}}),A=t,D=e.Types,q=D.CaptureScope,C=D.AssignScope,F=D.IncrementScope,A.registerTag("increment",{parse:function(t){var e=t.args.match(K);et(e,"illegal identifier "+t.args),this.variable=e[0]},render:function(t,e){var r=t.findContextFor(this.variable,function(t){var e=Object.getPrototypeOf(t);return e!==q&&e!==C});r||(r=J(F),t.unshift(r)),"number"!=typeof r[this.variable]&&(r[this.variable]=0);var n=r[this.variable];return r[this.variable]++,n}}),L=e,I=/\S+/,(P=t).registerTag("layout",{parse:function(t,e){var r=I.exec(t.args);r&&(this.staticLayout=r[0]),(r=Q.exec(t.args))&&(this.layout=r[0]),this.tpls=P.parser.parse(e)},render:function(o,s){return B(this,void 0,void 0,function(){var e,r,n,i;return U(this,function(t){switch(t.label){case 0:return et(e=o.opts.dynamicPartials?L.evalValue(this.layout,o):this.staticLayout,"cannot apply layout with empty filename"),o.opts.blockMode="store",[4,P.renderer.renderTemplates(this.tpls,o)];case 1:return r=t.sent(),void 0===o.opts.blocks[""]&&(o.opts.blocks[""]=r),[4,P.getTemplate(e,o.opts.root)];case 2:return n=t.sent(),o.push(s),o.opts.blockMode="output",[4,P.renderer.renderTemplates(n,o)];case 3:return i=t.sent(),o.pop(s),[2,i]}})})}}),P.registerTag("block",{parse:function(t,e){var r=this,n=/\w+/.exec(t.args);this.block=n?n[0]:"",this.tpls=[];var i=P.parser.parseStream(e).on("tag:endblock",function(){return i.stop()}).on("template",function(t){return r.tpls.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});i.start()},render:function(i){return B(this,void 0,void 0,function(){var e,r,n;return U(this,function(t){switch(t.label){case 0:return void 0===(e=i.opts.blocks[this.block])?[3,1]:(n=e,[3,3]);case 1:return[4,P.renderer.renderTemplates(this.tpls,i)];case 2:n=t.sent(),t.label=3;case 3:return r=n,"store"===i.opts.blockMode?(i.opts.blocks[this.block]=r,[2,""]):[2,r]}})})}}),(V=t).registerTag("raw",{parse:function(t,e){var r=this;this.tokens=[];var n=V.parser.parseStream(e);n.on("token",function(t){"endraw"===t.name?n.stop():r.tokens.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")}),n.start()},render:function(t,e){return this.tokens.map(function(t){return t.raw}).join("")}}),$=t,Y=e,H=new RegExp("^("+K.source+")\\s+in\\s+("+Q.source+")(?:\\s+"+Z.source+")*$"),$.registerTag("tablerow",{parse:function(t,e){var r,n=this,i=H.exec(t.args);et(i,"illegal tag: "+t.raw),this.variable=i[1],this.collection=i[2],this.templates=[];var o=$.parser.parseStream(e).on("start",function(){return r=n.templates}).on("tag:endtablerow",function(t){return o.stop()}).on("template",function(t){return r.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});o.start()},render:function(c,l){return B(this,void 0,void 0,function(){var e,r,n,o,i,s,u,a=this;return U(this,function(t){switch(t.label){case 0:return e=Y.evalExp(this.collection,c)||[],r=l.offset||0,n=void 0===l.limit?e.length:l.limit,e=e.slice(r,r+n),o=l.cols||e.length,i=e.map(function(t,e){var r={};return r[a.variable]=t,r}),u="",[4,pt(i,function(n,i){return B(a,void 0,void 0,function(){var e,r;return U(this,function(t){switch(t.label){case 0:return s=Math.floor(i/o)+1,1==(e=i%o+1)&&(1!==s&&(u+="</tr>"),u+='<tr class="row'+s+'">'),u+='<td class="col'+e+'">',c.push(n),r=u,[4,$.renderer.renderTemplates(this.templates,c)];case 1:return u=r+t.sent(),u+="</td>",c.pop(n),[2,u]}})})})];case 1:return t.sent(),0<s&&(u+="</tr>"),[2,u]}})})}}),z=e,(N=t).registerTag("unless",{parse:function(e,t){var r,n=this;this.templates=[],this.elseTemplates=[];var i=N.parser.parseStream(t).on("start",function(t){r=n.templates,n.cond=e.args}).on("tag:else",function(){return r=n.elseTemplates}).on("tag:endunless",function(t){return i.stop()}).on("template",function(t){return r.push(t)}).on("end",function(t){throw new Error("tag "+e.raw+" not closed")});i.start()},render:function(t,e){var r=z.evalExp(this.cond,t);return z.isFalsy(r)?N.renderer.renderTemplates(this.templates,t):N.renderer.renderTemplates(this.elseTemplates,t)}})}var dt=["January","February","March","April","May","June","July","August","September","October","November","December"],gt=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],vt=dt.map(wt),mt=gt.map(wt),yt={1:"st",2:"nd",3:"rd",default:"th"};function wt(t){return t.slice(0,3)}var bt={daysInMonth:function(t){return[31,bt.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31]},getDayOfYear:function(t){for(var e=0,r=0;r<t.getMonth();++r)e+=bt.daysInMonth(t)[r];return e+t.getDate()},getWeekOfYear:function(t,e){var r=this.getDayOfYear(t)+(e-t.getDay()),n=7-new Date(t.getFullYear(),0,1).getDay()+e;return xt.pad(Math.floor((r-n)/7)+1,2)},isLeapYear:function(t){var e=t.getFullYear();return!(0!=(3&e)||!(e%100||e%400==0&&e))},getSuffix:function(t){var e=t.getDate().toString(),r=parseInt(e.slice(-1));return yt[r]||yt.default},century:function(t){return parseInt(t.getFullYear().toString().substring(0,2),10)}},xt={pad:function(t,e,r){r||(r="0");for(var n=t.toString(),i=e-n.length;0<i--;)n=r+n;return n}},Tt={a:function(t){return mt[t.getDay()]},A:function(t){return gt[t.getDay()]},b:function(t){return vt[t.getMonth()]},B:function(t){return dt[t.getMonth()]},c:function(t){return t.toLocaleString()},C:function(t){return bt.century(t)},d:function(t){return xt.pad(t.getDate(),2)},e:function(t){return xt.pad(t.getDate(),2," ")},H:function(t){return xt.pad(t.getHours(),2)},I:function(t){return xt.pad(t.getHours()%12||12,2)},j:function(t){return xt.pad(bt.getDayOfYear(t),3)},k:function(t){return xt.pad(t.getHours(),2," ")},l:function(t){return xt.pad(t.getHours()%12||12,2," ")},L:function(t){return xt.pad(t.getMilliseconds(),3)},m:function(t){return xt.pad(t.getMonth()+1,2)},M:function(t){return xt.pad(t.getMinutes(),2)},p:function(t){return t.getHours()<12?"AM":"PM"},P:function(t){return t.getHours()<12?"am":"pm"},q:function(t){return bt.getSuffix(t)},s:function(t){return Math.round(t.valueOf()/1e3)},S:function(t){return xt.pad(t.getSeconds(),2)},u:function(t){return t.getDay()||7},U:function(t){return bt.getWeekOfYear(t,0)},w:function(t){return t.getDay()},W:function(t){return bt.getWeekOfYear(t,1)},x:function(t){return t.toLocaleDateString()},X:function(t){return t.toLocaleTimeString()},y:function(t){return t.getFullYear().toString().substring(2,4)},Y:function(t){return t.getFullYear()},z:function(t){var e=t.getTimezoneOffset()/60*100;return(0<e?"-":"+")+xt.pad(Math.abs(e),4)},"%":function(){return"%"}};Tt.h=Tt.b,Tt.N=Tt.L;var Et={"&":"&","<":"<",">":">",'"':""","'":"'"},kt={"&":"&","<":"<",">":">",""":'"',"'":"'"},St={abs:function(t){return Math.abs(t)},append:function(t,e){return t+e},capitalize:function(t){return Mt(t).charAt(0).toUpperCase()+t.slice(1)},ceil:function(t){return Math.ceil(t)},concat:function(t,e){return Array.prototype.concat.call(t,e)},date:function(t,e){var r,n=t;return"now"===t?n=new Date:W(t)&&(n=new Date(t)),(r=n)instanceof Date&&!isNaN(r.getTime())?function(t,e){for(var r="",n=e;;){var i=/%./g,o=i.exec(n);if(!o)return r+n;r+=n.slice(0,i.lastIndex-2),n=n.slice(i.lastIndex);var s=o[0].charAt(1),u=Tt[s];r+=u?u.call(this,t):"%"+s}}(n,e):t},default:function(t,e){return ot(t)?t:e},divided_by:function(t,e){return t/e},downcase:function(t){return t.toLowerCase()},escape:_t,escape_once:function(t){return _t(Mt(t).replace(/&(amp|lt|gt|#34|#39);/g,function(t){return kt[t]}))},first:function(t){return t[0]},floor:function(t){return Math.floor(t)},join:function(t,e){return t.join(void 0===e?" ":e)},last:function(t){return y(t)},lstrip:function(t){return Mt(t).replace(/^\s+/,"")},map:function(t,e){return t.map(function(t){return t[e]})},minus:Ot(function(t,e){return t-e}),modulo:Ot(function(t,e){return t%e}),newline_to_br:function(t){return t.replace(/\n/g,"<br />")},plus:Ot(function(t,e){return Number(t)+Number(e)}),prepend:function(t,e){return e+t},remove:function(t,e){return t.split(e).join("")},remove_first:function(t,e){return t.replace(e,"")},replace:function(t,e,r){return Mt(t).split(e).join(r)},replace_first:function(t,e,r){return Mt(t).replace(e,r)},reverse:function(t){return t.reverse()},round:function(t,e){var r=Math.pow(10,e||0);return Math.round(t*r,e)/r},rstrip:function(t){return Mt(t).replace(/\s+$/,"")},size:function(t){return t.length},slice:function(t,e,r){return void 0===r&&(r=1),t.slice(e,e+r)},sort:function(t,e){return t.sort(e)},split:function(t,e){return Mt(t).split(e)},strip:function(t){return Mt(t).trim()},strip_html:function(t){return Mt(t).replace(/<script.*?<\/script>|<!--.*?-->|<style.*?<\/style>|<.*?>/g,"")},strip_newlines:function(t){return Mt(t).replace(/\n/g,"")},times:function(t,e){return t*e},truncate:function(t,e,r){return r=void 0===r?"...":r,e=e||16,(t=Mt(t)).length<=e?t:t.substr(0,e-r.length)+r},truncatewords:function(t,e,r){void 0===r&&(r="...");var n=t.split(" "),i=n.slice(0,e).join(" ");return n.length>e&&(i+=r),i},uniq:function(t){var e={};return(t||[]).filter(function(t){return!e.hasOwnProperty(t)&&(e[t]=!0)})},upcase:function(t){return Mt(t).toUpperCase()},url_decode:function(t){return t.split("+").map(decodeURIComponent).join(" ")},url_encode:function(t){return t.split(" ").map(encodeURIComponent).join("+")}};function _t(t){return Mt(t).replace(/&|<|>|"|'/g,function(t){return Et[t]})}function Rt(t){var e=(t+"").split(".");return 1<e.length?e[1].length:0}function Mt(t){return t+""}function Ot(o){return function(t,e){var r,n,i=(r=t,n=e,Math.max(Rt(r),Rt(n)));return o(t,e).toFixed(i)}}function jt(r,t){return function(t,e){for(var r in t=t||{})if(t.hasOwnProperty(r)&&!1===e(t[r],r,t))break;return t}(St,function(t,e){return r.registerFilter(e,t)})}return jt.filters=St,function(){function e(t){(t=m({root:["."],cache:!1,extname:"",dynamicPartials:!0,trim_tag_right:!1,trim_tag_left:!1,trim_value_right:!1,trim_value_left:!1,greedy:!0,strict_filters:!1,strict_variables:!1},t)).root=function(t){if(G(t))return t;if(W(t))return[t];throw new TypeError("illegal root: "+t)}(t.root),t.cache&&(this.cache={}),this.options=t,this.tags=at(),this.filters=function(a){a=m({},a);var c={},e={render:function(t,e){var r=this.args.map(function(t){return it(t,e)});return r.unshift(t),this.filter.apply(null,r)},parse:function(t){var e=A.exec(t);et(e,"illegal filter: "+t);var r=e[1],n=e[2]||"",i=c[r];if("function"!=typeof i){if(a.strict_filters)throw new TypeError("undefined filter: "+r);return this.name=r,this.filter=function(t){return t},this.args=[],this}for(var o=[];e=ct.exec(n.trim());){var s=e[0],u=new RegExp(s+"\\s*:","g").exec(e.input);u&&u.index===e.index?o.push("'"+s+"'"):o.push(s)}return this.name=r,this.filter=i,this.args=o,this}};return{construct:function(t){return J(e).parse(t)},register:function(t,e){c[t]=e},clear:function(){c={}}}}(t),this.parser=lt(this.tags,this.filters),this.renderer=J(ut),ht(this,e),jt(this)}return e.prototype.parse=function(t,e){var r=N(t,e,this.options);return this.parser.parse(r)},e.prototype.render=function(t,e,r){r=m({},this.options,r);var n=new $(e,r);return this.renderer.renderTemplates(t,n)},e.prototype.parseAndRender=function(r,n,i){return B(this,void 0,void 0,function(){var e;return U(this,function(t){switch(t.label){case 0:return[4,this.parse(r)];case 1:return e=t.sent(),[2,this.render(e,n,i)]}})})},e.prototype.getTemplate=function(n,i){return B(this,void 0,void 0,function(){var r,e=this;return U(this,function(t){switch(t.label){case 0:return[4,H(n,i,this.options)];case 1:return r=t.sent(),[2,this.respectCache(r,function(){return B(e,void 0,void 0,function(){var e;return U(this,function(t){switch(t.label){case 0:return[4,function(n){return B(this,void 0,void 0,function(){return U(this,function(t){return[2,new Promise(function(t,e){var r=new XMLHttpRequest;r.onload=function(){200<=r.status&&r.status<300?t(r.responseText):e(new Error(r.statusText))},r.onerror=function(){e(new Error("An error occurred whilst receiving the response."))},r.open("GET",n),r.send()})]})})}(r)];case 1:return e=t.sent(),[2,this.parse(e,r)]}})})})]}})})},e.prototype.renderFile=function(r,n,i){return B(this,void 0,void 0,function(){var e;return U(this,function(t){switch(t.label){case 0:return i=m({},i),[4,this.getTemplate(r,i.root)];case 1:return e=t.sent(),[2,this.render(e,n,i)]}})})},e.prototype.respectCache=function(n,i){return B(this,void 0,void 0,function(){var e,r;return U(this,function(t){switch(t.label){case 0:return(e=this.options.cache)&&this.cache[n]?[2,this.cache[n]]:[4,i()];case 1:return r=t.sent(),e&&(this.cache[n]=r),[2,r]}})})},e.prototype.evalValue=function(t,e){var r=this.parser.parseValue(t.trim());return this.renderer.evalValue(r,e)},e.prototype.registerFilter=function(t,e){return this.filters.register(t,e)},e.prototype.registerTag=function(t,e){return this.tags.register(t,e)},e.prototype.plugin=function(t){return t.call(this,e)},e.prototype.express=function(n){n=n||{};var i=this;return function(t,e,r){et(G(this.root)||W(this.root),"illegal views root, are you using express.js?"),n.root=this.root,i.renderFile(t,e,n).then(function(t){return r(null,t)},r)}},(e.default=e).isTruthy=ot,e.isFalsy=st,e.evalExp=nt,e.evalValue=it,e.Types={ParseError:P,TokenizationError:F,RenderBreakError:I,AssertionError:V,AssignScope:{},CaptureScope:{},IncrementScope:{},DecrementScope:{}},e}()}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Liquid=e()}(this,function(){"use strict";var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function e(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var c=function(){return(c=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var i in e=arguments[r])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function h(o,s,u,a){return new(u||(u=Promise))(function(t,e){function r(t){try{i(a.next(t))}catch(t){e(t)}}function n(t){try{i(a.throw(t))}catch(t){e(t)}}function i(e){e.done?t(e.value):new u(function(t){t(e.value)}).then(r,n)}i((a=a.apply(o,s||[])).next())})}function d(r,n){var i,o,s,t,u={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;u;)try{if(i=1,o&&(s=2&e[0]?o.return:e[0]?o.throw||((s=o.return)&&s.call(o),0):o.next)&&!(s=s.call(o,e[1])).done)return s;switch(o=0,s&&(e=[2&e[0],s.value]),e[0]){case 0:case 1:s=e;break;case 4:return u.label++,{value:e[1],done:!1};case 5:u.label++,o=e[1],e=[0];continue;case 7:e=u.ops.pop(),u.trys.pop();continue;default:if(!(s=0<(s=u.trys).length&&s[s.length-1])&&(6===e[0]||2===e[0])){u=0;continue}if(3===e[0]&&(!s||e[1]>s[0]&&e[1]<s[3])){u.label=e[1];break}if(6===e[0]&&u.label<s[1]){u.label=s[1],s=e;break}if(s&&u.label<s[2]){u.label=s[2],u.ops.push(e);break}s[2]&&u.ops.pop(),u.trys.pop();continue}e=n.call(r,u)}catch(t){e=[6,t],o=0}finally{i=s=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}var i=Object.prototype.toString,o=Array.prototype.toString;function l(t){return"[object String]"===i.call(t)}function s(t){return"function"==typeof t}function u(t){return f(t)?"":s(t.to_liquid)?u(t.to_liquid()):s(t.toLiquid)?u(t.toLiquid()):s(t.to_s)?t.to_s():-1<[i,o].indexOf(t.toString)?(e=t,r=[],JSON.stringify(e,function(t,e){if(m(e)){if(-1!==r.indexOf(e))return;r.push(e)}return e})):s(t.toString)?t.toString():i.call(t);var e,r}function a(t){return Object.create(t)}function f(t){return null==t}function p(t){return"[object Array]"===i.call(t)}function g(t,e){for(var r in t=t||{})if(t.hasOwnProperty(r)&&!1===e(t[r],r,t))break;return t}function v(t){return t[t.length-1]}function m(t){var e=typeof t;return null!==t&&("object"===e||"function"===e)}function w(t,e,r){void 0===r&&(r=" ");for(var n=e-(t=String(t)).length;0<n--;)t=r+t;return t}var t=new RegExp(/'[^']*'/.source+"|"+/"[^"]*"/.source),y=new RegExp("(?:"+t.source+"|[^'\"])*"),r=/-?\d+\.?\d*|\.?\d+/,b=/true|false/,x=/[\w-]+[?]?/,T=new RegExp("\\[(?:"+t.source+"|[\\w-\\.]+)\\]"),E=new RegExp("(?:"+t.source+"|"+b.source+"|"+r.source+")"),k=new RegExp(x.source+"(?:\\."+x.source+"|"+T.source+")*"),S=new RegExp("(?:"+k.source+"|"+r.source+")"),q=new RegExp("\\("+S.source+"\\.\\."+S.source+"\\)"),R=new RegExp("\\(("+S.source+")\\.\\.("+S.source+")\\)"),_=new RegExp("(?:"+k.source+"|"+E.source+"|"+q.source+")"),O=new RegExp("(?:"+x.source+")\\s*:\\s*(?:"+_.source+")"),M=new RegExp("("+x.source+")\\s*:\\s*("+_.source+")","g"),L=new RegExp("^\\s*("+x.source+")\\s*([\\s\\S]*?)\\s*$"),P=new RegExp("^"+E.source+"$","i"),A=new RegExp("^"+k.source+"$"),j=new RegExp("^"+r.source+"$"),U=new RegExp("^"+b.source+"$","i"),F=new RegExp("^"+t.source+"$"),D=new RegExp("^"+R.source+"$"),$=new RegExp("^"+/-?\d+/.source+"$"),H=new RegExp("(?:"+x.source+"\\s*:\\s*)?"+_.source),C=new RegExp(H.source+"(\\s*,\\s*"+H.source+")*"),N=new RegExp(x.source+"(?:\\s*:\\s*"+C.source+")?","g"),Y=new RegExp("("+x.source+")(?:\\s*:\\s*("+C.source+"))?"),z=new RegExp("^"+Y.source+"$"),I=[/\s+or\s+/,/\s+and\s+/,/==|!=|<=|>=|<|>|\s+contains\s+/];function G(){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}var V=function(){function t(t,e){this.input=e.input,this.line=e.line,this.file=e.file,this.originalError=t,this.token=e}return t.prototype.captureStackTrace=function(t){this.name=t.constructor.name,G.call(t);var e,i,o,r,s,n=this.originalError,u=(e=this.input,i=this.line,o=e.split("\n"),r=Math.max(i-2,1),s=Math.min(i+3,o.length),function(t,e,r){1===arguments.length&&(e=t,t=0),r=r||1;for(var n=[],i=t;i<e;i+=r)n.push(i);return n}(r,s+1).map(function(t){var e=t===i?">> ":" ",r=w(String(t),String(s).length),n=o[t-1];return""+e+r+"| "+n}).join("\n"));this.message=function(t,e){t=t||"",e.file&&(t+=", file:"+e.file);e.line&&(t+=", line:"+e.line);return t}(n.message,this.token),this.stack=this.message+"\n"+u+"\n"+(this.stack||this.message)+(n.stack?"\nFrom "+n.stack:"")},t}(),W=function(n){function t(t,e){var r=n.call(this,{message:t},e)||this;return n.prototype.captureStackTrace.call(r,r),r}return e(t,n),t}(V);W.prototype=a(Error.prototype),W.prototype.constructor=W;var B=function(n){function t(t,e){var r=n.call(this,t,e)||this;return r.message=t.message,n.prototype.captureStackTrace.call(r,r),r}return e(t,n),t}(V);B.prototype=a(Error.prototype),B.prototype.constructor=B;var J=function(n){function t(t,e){var r=n.call(this,t,e.token)||this;return r.message=t.message,n.prototype.captureStackTrace.call(r,r),r}return e(t,n),t}(V);J.prototype=a(Error.prototype),J.prototype.constructor=J;var X=function(t){G.call(this),this.message=t+""};X.prototype=a(Error.prototype),X.prototype.constructor=X;var K=function(t){G.call(this),this.message=t+""};function Q(t,e){if(!t)throw new K(e=e||"expect "+t+" to be true")}K.prototype=a(Error.prototype),K.prototype.constructor=K;var Z,tt,et={root:["."],cache:!1,extname:"",dynamicPartials:!0,trim_tag_right:!1,trim_tag_left:!1,trim_value_right:!1,trim_value_left:!1,greedy:!0,strict_filters:!1,strict_variables:!1};function rt(t){var e;return(t=t||{}).hasOwnProperty("root")&&(t.root=p(e=t.root)?e:l(e)?[e]:[]),t}(tt=Z||(Z={}))[tt.OUTPUT=0]="OUTPUT",tt[tt.STORE=1]="STORE";var nt=Z,it=function(){function t(t,e){void 0===t&&(t={}),void 0===e&&(e=et),this.blocks={},this.blockMode=nt.OUTPUT,this.opts=c({},et,e),this.contexts=[t||{}]}return t.prototype.getAll=function(){return this.contexts.reduce(function(t,e){return function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return e=m(e)?e:{},t.forEach(function(t){return function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);return t}(e,t)}),e}(t,e)},a(null))},t.prototype.get=function(t){var r=this,e=this.propertyAccessSeq(t),n=this.findContextFor(e[0])||v(this.contexts);return e.reduce(function(t,e){return r.readProperty(t,e)},n)},t.prototype.set=function(t,r){var n=this.propertyAccessSeq(t),i=this.findContextFor(n[0])||v(this.contexts);n.some(function(t,e){return!m(i)||(e===n.length-1?(i[t]=r,!0):(void 0===i[t]&&(i[t]={}),void(i=i[t])))})},t.prototype.unshift=function(t){return this.contexts.unshift(t)},t.prototype.push=function(t){return this.contexts.push(t)},t.prototype.pop=function(e){if(!arguments.length)return this.contexts.pop();var t=this.contexts.findIndex(function(t){return t===e});if(-1===t)throw new TypeError("scope not found, cannot pop");return this.contexts.splice(t,1)[0]},t.prototype.findContextFor=function(t,e){void 0===e&&(e=function(){return!0});for(var r=this.contexts.length-1;0<=r;r--){var n=this.contexts[r];if(e(n)&&t in n)return n}return null},t.prototype.readProperty=function(t,e){var r,n;if(f(t)?r=void 0:(t=function(t){if(s(t.to_liquid))return t.to_liquid();if(s(t.toLiquid))return t.toLiquid();return t}(t),r="size"===e?f((n=t).size)&&(p(n)||l(n))?n.length:n.size:t[e],s(t.liquid_method_missing)&&(r=t.liquid_method_missing(e))),f(r)&&this.opts.strict_variables)throw new TypeError("undefined variable: "+e);return r},t.prototype.propertyAccessSeq=function(t){t=String(t);for(var e,r,n=[],i="",o=0;o<t.length;)switch(t[o]){case"[":u();var s=t[o+1];o=/['"]/.test(s)?(Q(-1!==(e=t.indexOf(s,o+2)),"unbalanced "+s+": "+t),i=t.slice(o+2,e),u(),e+2):(Q(-1!==(e=ot(t,o+1)),"unbalanced []: "+t),i=t.slice(o+1,e),r=i,$.test(r)||(i=String(this.get(i))),u(),e+1);break;case".":u(),o++;break;default:i+=t[o],o++}if(u(),!n.length)throw new TypeError('invalid path:"'+t+'"');return n;function u(){i.length&&n.push(i),i=""}},t}();function ot(t,e){for(var r=1,n=e;n<t.length;n++)if("["===t[n]&&r++,"]"===t[n]&&0===--r)return n;return-1}var st=function(){},ut=function(){},at=function(){},ct=function(){},lt=Object.freeze({AssignScope:ut,CaptureScope:st,IncrementScope:at,DecrementScope:ct,ParseError:B,TokenizationError:W,RenderBreakError:X,AssertionError:K});var ft={readFile:function(n){return h(this,void 0,void 0,function(){return d(this,function(t){return[2,new Promise(function(t,e){var r=new XMLHttpRequest;r.onload=function(){200<=r.status&&r.status<300?t(r.responseText):e(new Error(r.statusText))},r.onerror=function(){e(new Error("An error occurred whilst receiving the response."))},r.open("GET",n),r.send()})]})})},resolve:function(t,e,i){return t.length&&"/"!==v(t)&&(t+="/"),function(t,e){var r=document.createElement("base");r.href=t;var n=document.getElementsByTagName("head")[0];n.insertBefore(r,n.firstChild);var i=document.createElement("a");i.href=e;var o=i.href;return n.removeChild(r),o}(t,e).replace(/^(\w+:\/\/[^/]+)(\/[^?]+)/,function(t,e,r){var n=r.split("/").pop();return/\.\w+$/.test(n)?t:e+r+i})},exists:function(){return h(this,void 0,void 0,function(){return d(this,function(t){return[2,!0]})})}};var pt,ht,dt=function(t,e,r,n,i){this.line=i,this.raw=t,this.input=r,this.file=n},gt=function(s){function t(t,e,r,n,i){var o=s.call(this,t,e,r,n,i)||this;return o.type="html",o.value=t,o}return e(t,s),t}(dt),vt=function(s){function t(t,e,r,n,i){var o=s.call(this,t,e,r,n,i)||this;return o.trimLeft="-"===t[2],o.trimRight="-"===t[t.length-3],o.value=t.slice(o.trimLeft?3:2,o.trimRight?-3:-2).trim(),o}return e(t,s),t}(dt),mt=function(u){function t(t,e,r,n,i){var o=u.call(this,t,e,r,n,i)||this;o.type="tag";var s=o.value.match(L);if(!s)throw new W("illegal tag syntax",o);return o.name=s[1],o.args=s[2],o}return e(t,u),t}(vt),wt=function(s){function t(t,e,r,n,i){var o=s.call(this,t,e,r,n,i)||this;return o.type="output",o}return e(t,s),t}(vt);(ht=pt||(pt={}))[ht.HTML=0]="HTML",ht[ht.OUTPUT=1]="OUTPUT",ht[ht.TAG=2]="TAG";var yt=function(){function t(t){void 0===t&&(t=et),this.options=t}return t.prototype.tokenize=function(t,e){for(var r=[],n=0,i=1,o=pt.HTML,s="",u=0;n<t.length;){"\n"===t[n]&&i++;var a=t.substr(n,2);if(o===pt.HTML){if("{{"===a||"{%"===a){s&&r.push(new gt(s,u,t,e,i)),u=n,n+=2,o="{{"===(s=a)?pt.OUTPUT:pt.TAG;continue}}else{if(o===pt.OUTPUT&&"}}"===a){s+="}}",r.push(new wt(s,u,t,e,i)),s="",u=n+=2,o=pt.HTML;continue}if("%}"===a){s+="%}",r.push(new mt(s,u,t,e,i)),s="",u=n+=2,o=pt.HTML;continue}}s+=t[n++]}return s&&r.push(new gt(s,u,t,e,i)),function(s,u){u=c({greedy:!0},u);var a=!1;s.forEach(function(t,e){var r,n,i,o;i=t,o=u,!a&&("tag"===i.type?i.trimLeft||o.trim_tag_left:"output"===i.type?i.trimLeft||o.trim_value_left:void 0)&&function(t,e){if(t&&"html"===t.type){var r=e?/\s+$/g:/[\t\r ]*$/g;t.value=t.value.replace(r,"")}}(s[e-1],u.greedy),"tag"===t.type&&"raw"===t.name&&(a=!0),"tag"===t.type&&"endraw"===t.name&&(a=!1),r=t,n=u,!a&&("tag"===r.type?r.trimRight||n.trim_tag_right:"output"===r.type?r.trimRight||n.trim_value_right:void 0)&&function(t,e){if(t&&"html"===t.type){var r=e?/^\s+/g:/^[\t\r ]*\n?/g;t.value=t.value.replace(r,"")}}(s[e+1],u.greedy)})}(r,this.options),r},t}(),bt=function(){function t(){}return t.prototype.renderTemplates=function(u,a){return h(this,void 0,void 0,function(){var e,r,n,i,o,s;return d(this,function(t){switch(t.label){case 0:Q(a,"unable to evalTemplates: scope undefined"),e="",r=0,n=u,t.label=1;case 1:if(!(r<n.length))return[3,6];i=n[r],t.label=2;case 2:return t.trys.push([2,4,,5]),o=e,[4,i.render(a)];case 3:return e=o+t.sent(),[3,5];case 4:if((s=t.sent())instanceof X)throw s.resolvedHTML=e,s;throw s instanceof J?s:new J(s,i);case 5:return r++,[3,1];case 6:return[2,e]}})})},t}(),xt={"==":function(t,e){return t===e},"!=":function(t,e){return t!==e},">":function(t,e){return null!==t&&null!==e&&e<t},"<":function(t,e){return null!==t&&null!==e&&t<e},">=":function(t,e){return null!==t&&null!==e&&e<=t},"<=":function(t,e){return null!==t&&null!==e&&t<=e},contains:function(t,e){return!!t&&("function"==typeof t.indexOf&&-1<t.indexOf(e))},and:function(t,e){return kt(t)&&kt(e)},or:function(t,e){return kt(t)||kt(e)}};function Tt(t,e){Q(e,"unable to evalExp: scope undefined");for(var r,n=I,i=0;i<n.length;i++){var o=n[i],s=new RegExp("^("+y.source+")("+o.source+")("+y.source+")$");if(r=t.match(s)){var u=Tt(r[1],e);return(0,xt[r[2].trim()])(u,Tt(r[3],e))}}if(r=t.match(D)){for(var a=Et(r[1],e),c=Et(r[2],e),l=[],f=a;f<=c;f++)l.push(f);return l}return Et(t,e)}function Et(t,e){if(t=t&&t.trim()){if(r=t,P.test(r))return function(t){var e=t.match(j);if(e)return Number(t);if(e=t.match(U))return"true"===t.toLowerCase();if(e=t.match(F))return t.slice(1,-1);throw new TypeError("cannot parse '"+t+"' as literal")}(t);var r,n;if(n=t,A.test(n))return e.get(t);throw new TypeError("cannot eval '"+t+"' as value")}}function kt(t){return!St(t)}function St(t){return!1===t||null==t}var qt=function(t,e){var r;for(M.lastIndex=0;r=M.exec(t);){var n=r[1],i=r[2];this[n]=Et(i,e)}},Rt=function(t){this.token=t},_t=function(o){function s(t,e,r){var n=o.call(this,t)||this;n.name=t.name;var i=s.impls[t.name];return Q(i,"tag "+t.name+" not found"),n.impl=a(i),n.impl.liquid=r,n.impl.parse&&n.impl.parse(t,e),n}return e(s,o),s.prototype.render=function(n){return h(this,void 0,void 0,function(){var e,r;return d(this,function(t){switch(t.label){case 0:return e=new qt(this.token.args,n),"function"!=typeof(r=this.impl).render?[2,""]:[4,r.render(n,e)];case 1:return[2,u(t.sent())]}})})},s.register=function(t,e){s.impls[t]=e},s.clear=function(){s.impls={}},s.impls={},s}(Rt),Ot=new RegExp(""+_.source,"g"),Mt=function(){function s(t,e){void 0===e&&(e=!1);var r=z.exec(t);Q(r,"illegal filter: "+t);var n=r[1],i=r[2]||"",o=s.impls[n];if(!o&&e)throw new TypeError("undefined filter: "+n);this.name=n,this.impl=o||function(t){return t},this.args=this.parseArgs(i)}return s.prototype.parseArgs=function(t){for(var e,r=[];e=Ot.exec(t.trim());){var n=e[0],i=new RegExp(n+"\\s*:","g").exec(e.input);i&&i.index===e.index?r.push("'"+n+"'"):r.push(n)}return r},s.prototype.render=function(t,e){var r=this.args.map(function(t){return Et(t,e)});return r.unshift(t),this.impl.apply(null,r)},s.register=function(t,e){s.impls[t]=e},s.clear=function(){s.impls={}},s.impls={},s}(),Lt=function(){function t(t,e){this.handlers={},this.tokens=t,this.parseToken=e}return t.prototype.on=function(t,e){return this.handlers[t]=e,this},t.prototype.trigger=function(t,e){var r=this.handlers[t];if("function"==typeof r)return r(e),!0},t.prototype.start=function(){var t;for(this.trigger("start");!this.stopRequested&&(t=this.tokens.shift());)if(!(this.trigger("token",t)||"tag"===t.type&&this.trigger("tag:"+t.name,t))){var e=this.parseToken(t,this.tokens);this.trigger("template",e)}return this.stopRequested||this.trigger("end"),this},t.prototype.stop=function(){return this.stopRequested=!0,this},t}(),Pt=function(){function t(t,e){var r,n=(r=t,_.exec(r));Q(n,"illegal value string: "+t);var i=n[0];t=t.substr(n.index+n[0].length);for(var o=[];n=N.exec(t);)o.push([n[0].trim()]);this.initial=i,this.filters=o.map(function(t){return new Mt(t,e)})}return t.prototype.value=function(r){return this.filters.reduce(function(t,e){return e.render(t,r)},Tt(this.initial,r))},t}(),At=function(n){function t(t,e){var r=n.call(this,t)||this;return r.value=new Pt(t.value,e),r}return e(t,n),t.prototype.render=function(e){return h(this,void 0,void 0,function(){return d(this,function(t){switch(t.label){case 0:return[4,this.value.value(e)];case 1:return[2,u(t.sent())]}})})},t}(Rt),jt=function(r){function t(t){var e=r.call(this,t)||this;return e.str=t.value,e}return e(t,r),t.prototype.render=function(){return h(this,void 0,void 0,function(){return d(this,function(t){return[2,this.str]})})},t}(Rt),Ut=function(){function t(t){this.liquid=t}return t.prototype.parse=function(t){for(var e,r=[];e=t.shift();)r.push(this.parseToken(e,t));return r},t.prototype.parseToken=function(e,t){try{return"tag"===e.type?new _t(e,t,this.liquid):"output"===e.type?new At(e,this.liquid.options.strict_filters):new jt(e)}catch(t){throw new B(t,e)}},t.prototype.parseStream=function(t){var r=this;return new Lt(t,function(t,e){return r.parseToken(t,e)})},t}(),Ft=new RegExp("("+x.source+")\\s*=([^]*)"),Dt={parse:function(t){var e=t.args.match(Ft);Q(e,"illegal token "+t.raw),this.key=e[1],this.value=e[2]},render:function(t){var e=new ut;return e[this.key]=this.liquid.evalValue(this.value,t),t.push(e),Promise.resolve("")}};function $t(r,n){var i=Promise.resolve("init"),o=[];return r.forEach(function(t,e){i=i.then(function(){return n(t,e,r)}).then(function(t){return o.push(t)})}),i.then(function(){return o})}var Ht=new RegExp("^("+x.source+")\\s+in\\s+("+_.source+")(?:\\s+"+O.source+")*(?:\\s+(reversed))?(?:\\s+"+O.source+")*$");var Ct={parse:function(t,e){var r,n=this,i=Ht.exec(t.args);Q(i,"illegal tag: "+t.raw),this.variable=i[1],this.collection=i[2],this.reversed=!!i[3],this.templates=[],this.elseTemplates=[];var o=this.liquid.parser.parseStream(e).on("start",function(){return r=n.templates}).on("tag:else",function(){return r=n.elseTemplates}).on("tag:endfor",function(){return o.stop()}).on("template",function(t){return r.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});o.start()},render:function(a,c){return h(this,void 0,void 0,function(){var n,e,r,i,o,s,u=this;return d(this,function(t){switch(t.label){case 0:return p(n=Tt(this.collection,a))||(l(n)&&0<n.length?n=[n]:m(n)&&(n=Object.keys(n).map(function(t){return[t,n[t]]}))),p(n)&&n.length?(e=c.offset||0,r=void 0===c.limit?n.length:c.limit,n=n.slice(e,e+r),this.reversed&&n.reverse(),i=n.map(function(t,e){var r={};return r[u.variable]=t,r.forloop={first:0===e,index:e+1,index0:e,last:e===n.length-1,length:n.length,rindex:n.length-e,rindex0:n.length-e-1},r}),o="",s=!1,[4,$t(i,function(n){return h(u,void 0,void 0,function(){var e,r;return d(this,function(t){switch(t.label){case 0:if(s)return[2];a.push(n),t.label=1;case 1:return t.trys.push([1,3,,4]),e=o,[4,this.liquid.renderer.renderTemplates(this.templates,a)];case 2:return o=e+t.sent(),[3,4];case 3:if(!((r=t.sent())instanceof X))throw r;return o+=r.resolvedHTML,"break"===r.message&&(s=!0),[3,4];case 4:return a.pop(n),[2]}})})})]):[2,this.liquid.renderer.renderTemplates(this.elseTemplates,a)];case 1:return t.sent(),[2,o]}})})}},Nt=new RegExp("("+x.source+")"),Yt={parse:function(t,e){var r=this,n=t.args.match(Nt);Q(n,t.args+" not valid identifier"),this.variable=n[1],this.templates=[];var i=this.liquid.parser.parseStream(e);i.on("tag:endcapture",function(){return i.stop()}).on("template",function(t){return r.templates.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")}),i.start()},render:function(n){return h(this,void 0,void 0,function(){var e,r;return d(this,function(t){switch(t.label){case 0:return[4,this.liquid.renderer.renderTemplates(this.templates,n)];case 1:return e=t.sent(),(r=new st)[this.variable]=e,n.push(r),[2]}})})}},zt={parse:function(t,e){var r=this;this.cond=t.args,this.cases=[],this.elseTemplates=[];var n=[],i=this.liquid.parser.parseStream(e).on("tag:when",function(t){r.cases.push({val:t.args,templates:n=[]})}).on("tag:else",function(){return n=r.elseTemplates}).on("tag:endcase",function(){return i.stop()}).on("template",function(t){return n.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});i.start()},render:function(t){for(var e=0;e<this.cases.length;e++){var r=this.cases[e];if(Tt(r.val,t)===Tt(this.cond,t))return this.liquid.renderer.renderTemplates(r.templates,t)}return this.liquid.renderer.renderTemplates(this.elseTemplates,t)}},It={parse:function(t,e){var r=this.liquid.parser.parseStream(e);r.on("token",function(t){"endcomment"===t.name&&r.stop()}).on("end",function(){throw new Error("tag "+t.raw+" not closed")}),r.start()}},Gt=/[^\s,]+/,Vt=new RegExp("with\\s+("+_.source+")"),Wt={parse:function(t){var e=Gt.exec(t.args);e&&(this.staticValue=e[0]),(e=_.exec(t.args))&&(this.value=e[0]),(e=Vt.exec(t.args))&&(this.with=e[1])},render:function(u,a){return h(this,void 0,void 0,function(){var e,r,n,i,o,s;return d(this,function(t){switch(t.label){case 0:return u.opts.dynamicPartials?F.exec(this.value)?(r=this.value.slice(1,-1),[4,this.liquid.parseAndRender(r,u.getAll(),u.opts)]):[3,2]:[3,4];case 1:return e=t.sent(),[3,3];case 2:e=Et(this.value,u),t.label=3;case 3:return[3,5];case 4:e=this.staticValue,t.label=5;case 5:return Q(e,"cannot include with empty filename"),n=u.blocks,i=u.blockMode,u.blocks={},u.blockMode=nt.OUTPUT,this.with&&(a[e]=Et(this.with,u)),[4,this.liquid.getTemplate(e,u.opts)];case 6:return o=t.sent(),u.push(a),[4,this.liquid.renderer.renderTemplates(o,u)];case 7:return s=t.sent(),u.pop(a),u.blocks=n,u.blockMode=i,[2,s]}})})}},Bt={parse:function(t){var e=t.args.match(x);Q(e,"illegal identifier "+t.args),this.variable=e[0]},render:function(t){var e=t.findContextFor(this.variable,function(t){return!(t instanceof st||t instanceof ut)});return e||(e=new ct,t.unshift(e)),"number"!=typeof e[this.variable]&&(e[this.variable]=0),--e[this.variable]}},Jt=new RegExp("^(?:("+_.source+")\\s*:\\s*)?(.*)$"),Xt=new RegExp(_.source,"g"),Kt={parse:function(t){var e=Jt.exec(t.args);Q(e,"illegal tag: "+t.raw),this.group=e[1]||"";var r=e[2];for(this.candidates=[];e=Xt.exec(r);)this.candidates.push(e[0]);Q(this.candidates.length,"empty candidates: "+t.raw)},render:function(t){var e="cycle:"+Et(this.group,t)+":"+this.candidates.join(","),r=t.opts.groups=t.opts.groups||{},n=r[e];void 0===n&&(n=r[e]=0);var i=this.candidates[n];return n=(n+1)%this.candidates.length,r[e]=n,Et(i,t)}},Qt={parse:function(t,e){var r,n=this;this.branches=[],this.elseTemplates=[];var i=this.liquid.parser.parseStream(e).on("start",function(){return n.branches.push({cond:t.args,templates:r=[]})}).on("tag:elsif",function(t){n.branches.push({cond:t.args,templates:r=[]})}).on("tag:else",function(){return r=n.elseTemplates}).on("tag:endif",function(){return i.stop()}).on("template",function(t){return r.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});i.start()},render:function(t){for(var e=0,r=this.branches;e<r.length;e++){var n=r[e];if(kt(Tt(n.cond,t)))return this.liquid.renderer.renderTemplates(n.templates,t)}return this.liquid.renderer.renderTemplates(this.elseTemplates,t)}},Zt={parse:function(t){var e=t.args.match(x);Q(e,"illegal identifier "+t.args),this.variable=e[0]},render:function(t){var e=t.findContextFor(this.variable,function(t){return!(t instanceof st||t instanceof ut)});e||(e=new at,t.unshift(e)),"number"!=typeof e[this.variable]&&(e[this.variable]=0);var r=e[this.variable];return e[this.variable]++,r}},te=/\S+/,ee={parse:function(t,e){var r=te.exec(t.args);r&&(this.staticLayout=r[0]),(r=_.exec(t.args))&&(this.layout=r[0]),this.tpls=this.liquid.parser.parse(e)},render:function(o,s){return h(this,void 0,void 0,function(){var e,r,n,i;return d(this,function(t){switch(t.label){case 0:return Q(e=o.opts.dynamicPartials?Et(this.layout,o):this.staticLayout,"cannot apply layout with empty filename"),o.blockMode=nt.STORE,[4,this.liquid.renderer.renderTemplates(this.tpls,o)];case 1:return r=t.sent(),void 0===o.blocks[""]&&(o.blocks[""]=r),[4,this.liquid.getTemplate(e,o.opts)];case 2:return n=t.sent(),o.push(s),o.blockMode=nt.OUTPUT,[4,this.liquid.renderer.renderTemplates(n,o)];case 3:return i=t.sent(),o.pop(s),[2,i]}})})}},re={parse:function(t,e){var r=this,n=/\w+/.exec(t.args);this.block=n?n[0]:"",this.tpls=[];var i=this.liquid.parser.parseStream(e).on("tag:endblock",function(){return i.stop()}).on("template",function(t){return r.tpls.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});i.start()},render:function(i){return h(this,void 0,void 0,function(){var e,r,n;return d(this,function(t){switch(t.label){case 0:return void 0===(e=i.blocks[this.block])?[3,1]:(n=e,[3,3]);case 1:return[4,this.liquid.renderer.renderTemplates(this.tpls,i)];case 2:n=t.sent(),t.label=3;case 3:return r=n,i.blockMode===nt.STORE?(i.blocks[this.block]=r,[2,""]):[2,r]}})})}},ne={parse:function(t,e){var r=this;this.tokens=[];var n=this.liquid.parser.parseStream(e);n.on("token",function(t){"endraw"===t.name?n.stop():r.tokens.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")}),n.start()},render:function(){return this.tokens.map(function(t){return t.raw}).join("")}},ie=new RegExp("^("+x.source+")\\s+in\\s+("+_.source+")(?:\\s+"+O.source+")*$"),oe={assign:Dt,for:Ct,capture:Yt,case:zt,comment:It,include:Wt,decrement:Bt,increment:Zt,cycle:Kt,if:Qt,layout:ee,block:re,raw:ne,tablerow:{parse:function(t,e){var r,n=this,i=ie.exec(t.args);Q(i,"illegal tag: "+t.raw),this.variable=i[1],this.collection=i[2],this.templates=[];var o=this.liquid.parser.parseStream(e).on("start",function(){return r=n.templates}).on("tag:endtablerow",function(){return o.stop()}).on("template",function(t){return r.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});o.start()},render:function(c,l){return h(this,void 0,void 0,function(){var e,r,n,o,i,s,u,a=this;return d(this,function(t){switch(t.label){case 0:return e=Tt(this.collection,c)||[],r=l.offset||0,n=void 0===l.limit?e.length:l.limit,e=e.slice(r,r+n),o=l.cols||e.length,i=e.map(function(t){var e={};return e[a.variable]=t,e}),u="",[4,$t(i,function(n,i){return h(a,void 0,void 0,function(){var e,r;return d(this,function(t){switch(t.label){case 0:return s=Math.floor(i/o)+1,1===(e=i%o+1)&&(1!==s&&(u+="</tr>"),u+='<tr class="row'+s+'">'),u+='<td class="col'+e+'">',c.push(n),r=u,[4,this.liquid.renderer.renderTemplates(this.templates,c)];case 1:return u=r+t.sent(),u+="</td>",c.pop(n),[2,u]}})})})];case 1:return t.sent(),0<s&&(u+="</tr>"),[2,u]}})})}},unless:{parse:function(t,e){var r,n=this;this.templates=[],this.elseTemplates=[];var i=this.liquid.parser.parseStream(e).on("start",function(){r=n.templates,n.cond=t.args}).on("tag:else",function(){return r=n.elseTemplates}).on("tag:endunless",function(){return i.stop()}).on("template",function(t){return r.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});i.start()},render:function(t){return St(Tt(this.cond,t))?this.liquid.renderer.renderTemplates(this.templates,t):this.liquid.renderer.renderTemplates(this.elseTemplates,t)}},break:{render:function(){return h(this,void 0,void 0,function(){return d(this,function(t){throw new X("break")})})}},continue:{render:function(){return h(this,void 0,void 0,function(){return d(this,function(t){throw new X("continue")})})}}},se={"&":"&","<":"<",">":">",'"':""","'":"'"},ue={"&":"&","<":"<",">":">",""":'"',"'":"'"};function ae(t){return String(t).replace(/&|<|>|"|'/g,function(t){return se[t]})}var ce={escape:ae,escape_once:function(t){return ae(String(t).replace(/&(amp|lt|gt|#34|#39);/g,function(t){return ue[t]}))},newline_to_br:function(t){return t.replace(/\n/g,"<br />")},strip_html:function(t){return String(t).replace(/<script.*?<\/script>|<!--.*?-->|<style.*?<\/style>|<.*?>/g,"")}},le={append:function(t,e){return t+e},prepend:function(t,e){return e+t},capitalize:function(t){return String(t).charAt(0).toUpperCase()+t.slice(1)},concat:function(t,e){return Array.prototype.concat.call(t,e)},lstrip:function(t){return String(t).replace(/^\s+/,"")},downcase:function(t){return t.toLowerCase()},upcase:function(t){return String(t).toUpperCase()},remove:function(t,e){return t.split(e).join("")},remove_first:function(t,e){return t.replace(e,"")},replace:function(t,e,r){return String(t).split(e).join(r)},replace_first:function(t,e,r){return String(t).replace(e,r)},rstrip:function(t){return String(t).replace(/\s+$/,"")},split:function(t,e){return String(t).split(e)},strip:function(t){return String(t).trim()},strip_newlines:function(t){return String(t).replace(/\n/g,"")},truncate:function(t,e,r){return r=void 0===r?"...":r,e=e||16,(t=String(t)).length<=e?t:t.substr(0,e-r.length)+r},truncatewords:function(t,e,r){void 0===r&&(r="...");var n=t.split(" "),i=n.slice(0,e).join(" ");return n.length>e&&(i+=r),i}},fe={abs:function(t){return Math.abs(t)},ceil:function(t){return Math.ceil(t)},divided_by:function(t,e){return t/e},floor:function(t){return Math.floor(t)},minus:he(function(t,e){return t-e}),modulo:he(function(t,e){return t%e}),round:function(t,e){var r=Math.pow(10,e||0);return Math.round(t*r)/r},plus:he(function(t,e){return Number(t)+Number(e)}),times:function(t,e){return t*e}};function pe(t){var e=String(t).split(".");return 1<e.length?e[1].length:0}function he(n){return function(t,e){var r=Math.max(pe(t),pe(e));return n(t,e).toFixed(r)}}var de={url_decode:function(t){return t.split("+").map(decodeURIComponent).join(" ")},url_encode:function(t){return t.split(" ").map(encodeURIComponent).join("+")}},ge={join:function(t,e){return t.join(void 0===e?" ":e)},last:function(t){return v(t)},first:function(t){return t[0]},map:function(t,e){return t.map(function(t){return t[e]})},reverse:function(t){return t.reverse()},sort:function(t,e){return t.sort(e)},size:function(t){return t.length},slice:function(t,e,r){return void 0===r&&(r=1),t.slice(e,e+r)},uniq:function(t){var e={};return(t||[]).filter(function(t){return!e.hasOwnProperty(t)&&(e[t]=!0)})}},ve=["January","February","March","April","May","June","July","August","September","October","November","December"],me=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],we=ve.map(xe),ye=me.map(xe),be={1:"st",2:"nd",3:"rd",default:"th"};function xe(t){return t.slice(0,3)}var Te={daysInMonth:function(t){return[31,Te.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31]},getDayOfYear:function(t){for(var e=0,r=0;r<t.getMonth();++r)e+=Te.daysInMonth(t)[r];return e+t.getDate()},getWeekOfYear:function(t,e){var r=this.getDayOfYear(t)+(e-t.getDay()),n=7-new Date(t.getFullYear(),0,1).getDay()+e;return w(String(Math.floor((r-n)/7)+1),2,"0")},isLeapYear:function(t){var e=t.getFullYear();return!(0!=(3&e)||!(e%100||e%400==0&&e))},getSuffix:function(t){var e=t.getDate().toString(),r=parseInt(e.slice(-1));return be[r]||be.default},century:function(t){return parseInt(t.getFullYear().toString().substring(0,2),10)}},Ee={a:function(t){return ye[t.getDay()]},A:function(t){return me[t.getDay()]},b:function(t){return we[t.getMonth()]},B:function(t){return ve[t.getMonth()]},c:function(t){return t.toLocaleString()},C:function(t){return Te.century(t)},d:function(t){return w(t.getDate(),2,"0")},e:function(t){return w(t.getDate(),2)},H:function(t){return w(t.getHours(),2,"0")},I:function(t){return w(String(t.getHours()%12||12),2,"0")},j:function(t){return w(Te.getDayOfYear(t),3,"0")},k:function(t){return w(t.getHours(),2)},l:function(t){return w(String(t.getHours()%12||12),2)},L:function(t){return w(t.getMilliseconds(),3,"0")},m:function(t){return w(t.getMonth()+1,2,"0")},M:function(t){return w(t.getMinutes(),2,"0")},p:function(t){return t.getHours()<12?"AM":"PM"},P:function(t){return t.getHours()<12?"am":"pm"},q:function(t){return Te.getSuffix(t)},s:function(t){return Math.round(t.valueOf()/1e3)},S:function(t){return w(t.getSeconds(),2,"0")},u:function(t){return t.getDay()||7},U:function(t){return Te.getWeekOfYear(t,0)},w:function(t){return t.getDay()},W:function(t){return Te.getWeekOfYear(t,1)},x:function(t){return t.toLocaleDateString()},X:function(t){return t.toLocaleTimeString()},y:function(t){return t.getFullYear().toString().substring(2,4)},Y:function(t){return t.getFullYear()},z:function(t){var e=t.getTimezoneOffset()/60*100;return(0<e?"-":"+")+w(String(Math.abs(e)),4,"0")},"%":function(){return"%"}};Ee.h=Ee.b,Ee.N=Ee.L;var ke=c({},ce,le,fe,de,{date:function(t,e){var r,n=t;return"now"===t?n=new Date:l(t)&&(n=new Date(t)),(r=n)instanceof Date&&!isNaN(r.getTime())?function(t,e){for(var r="",n=e;;){var i=/%./g,o=i.exec(n);if(!o)return r+n;r+=n.slice(0,i.lastIndex-2),n=n.slice(i.lastIndex);var s=o[0].charAt(1),u=Ee[s];r+=u?u.call(this,t):"%"+s}}(n,e):t}},{default:function(t,e){return kt(t)?t:e}},ge);return function(){function e(t){void 0===t&&(t={});var r=this,e=c({},et,rt(t));e.cache&&(this.cache={}),this.options=e,this.parser=new Ut(this),this.renderer=new bt,this.tokenizer=new yt(this.options),g(oe,function(t,e){return r.registerTag(e,t)}),g(ke,function(t,e){return r.registerFilter(e,t)})}return e.prototype.parse=function(t,e){var r=this.tokenizer.tokenize(t,e);return this.parser.parse(r)},e.prototype.render=function(t,e,r){var n=c({},this.options,rt(r)),i=new it(e,n);return this.renderer.renderTemplates(t,i)},e.prototype.parseAndRender=function(r,n,i){return h(this,void 0,void 0,function(){var e;return d(this,function(t){switch(t.label){case 0:return[4,this.parse(r)];case 1:return e=t.sent(),[2,this.render(e,n,i)]}})})},e.prototype.getTemplate=function(f,p){return h(this,void 0,void 0,function(){var e,r,n,i,o,s,u,a,c,l=this;return d(this,function(t){switch(t.label){case 0:e=rt(p),r=e.root?e.root.concat(this.options.root):this.options.root,n=r.map(function(t){return ft.resolve(t,f,l.options.extname)}),i=0,o=n,t.label=1;case 1:return i<o.length?(s=o[i],[4,ft.exists(s)]):[3,5];case 2:return t.sent()?this.options.cache&&this.cache[s]?[2,this.cache[s]]:(a=this.parse,[4,ft.readFile(s)]):[3,4];case 3:return u=a.apply(this,[t.sent(),s]),this.options.cache&&(this.cache[s]=u),[2,u];case 4:return i++,[3,1];case 5:throw(c=new Error("ENOENT")).message='ENOENT: Failed to lookup "'+f+'" in "'+r+'"',c.code="ENOENT",c}})})},e.prototype.renderFile=function(n,i,o){return h(this,void 0,void 0,function(){var e,r;return d(this,function(t){switch(t.label){case 0:return e=rt(o),[4,this.getTemplate(n,e)];case 1:return r=t.sent(),[2,this.render(r,i,o)]}})})},e.prototype.evalValue=function(t,e){return new Pt(t,this.options.strict_filters).value(e)},e.prototype.registerFilter=function(t,e){return Mt.register(t,e)},e.prototype.registerTag=function(t,e){return _t.register(t,e)},e.prototype.plugin=function(t){return t.call(this,e)},e.prototype.express=function(){var i=this;return function(t,e,r){var n={root:this.root};i.renderFile(t,e,n).then(function(t){return r(null,t)},r)}},(e.default=e).isTruthy=kt,e.isFalsy=St,e.evalExp=Tt,e.evalValue=Et,e.Types=lt,e}()}); | ||
//# sourceMappingURL=liquid.min.js.map |
{ | ||
"name": "liquidjs", | ||
"version": "7.0.0", | ||
"version": "7.0.2", | ||
"description": "Liquid template engine by pure JavaScript: compatible to shopify, easy to extend.", | ||
"main": "dist/liquid.common.js", | ||
"module": "src/index.js", | ||
"types": "dist/liquid.d.ts", | ||
"browser": "dist/liquid.js", | ||
"types": "src/index.d.ts", | ||
"scripts": { | ||
"lint": "eslint src/ test/ *.js", | ||
"unit": "mocha test/unit", | ||
"e2e": "mocha test/e2e", | ||
"lint": "eslint . --ext .ts --ext .js", | ||
"unit": "mocha 'test/unit/**/*.ts'", | ||
"e2e": "npm run build && mocha 'test/e2e/**/*.ts'", | ||
"test": "npm run unit && npm run e2e", | ||
"coverage": "nyc --reporter=html npm run unit", | ||
"coveralls": "nyc report --reporter=text-lcov | coveralls", | ||
"coverage-html": "nyc npm run unit && nyc report --reporter=html", | ||
"coverage-coveralls": "nyc npm run unit && nyc report --reporter=text-lcov | coveralls", | ||
"build": "rollup -c && ls -lh dist", | ||
@@ -23,2 +22,7 @@ "version": "npm run build && git add -A dist" | ||
}, | ||
"files": [ | ||
"dist", | ||
"LICENSE", | ||
"README.md" | ||
], | ||
"engines": { | ||
@@ -46,2 +50,5 @@ "node": ">=4.8.7" | ||
"@semantic-release/release-notes-generator": "^7.1.4", | ||
"@types/jsdom": "^12.2.2", | ||
"@types/mocha": "^5.2.6", | ||
"@typescript-eslint/eslint-plugin": "^1.3.0", | ||
"chai": "^4.2.0", | ||
@@ -61,7 +68,5 @@ "chai-as-promised": "^7.1.1", | ||
"mocha": "^5.2.0", | ||
"mock-fs": "^4.7.0", | ||
"nyc": "^13.1.0", | ||
"regenerator-runtime": "^0.12.1", | ||
"rollup": "^1.1.2", | ||
"rollup-plugin-alias": "^1.5.1", | ||
"rollup-plugin-shim": "^1.0.0", | ||
@@ -75,2 +80,3 @@ "rollup-plugin-typescript2": "^0.19.2", | ||
"ts-node": "^8.0.2", | ||
"tsconfig-paths": "^3.8.0", | ||
"typescript": "^3.3.3" | ||
@@ -87,3 +93,8 @@ }, | ||
] | ||
}, | ||
"nyc": { | ||
"extension": [ | ||
".ts" | ||
] | ||
} | ||
} |
@@ -215,3 +215,3 @@ # liquidjs | ||
See existing filter implementations here: <https://github.com/harttle/liquidjs/blob/master/filters.js> | ||
See existing filter implementations here: <https://github.com/harttle/liquidjs/tree/master/src/builtin/filters> | ||
@@ -236,3 +236,3 @@ ## Register Tags | ||
See existing tag implementations here: <https://github.com/harttle/liquidjs/blob/master/tags/> | ||
See existing tag implementations here: <https://github.com/harttle/liquidjs/tree/master/src/builtin/tags> | ||
@@ -239,0 +239,0 @@ ## Plugin API |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
1
0
636674
35
5100