Comparing version 8.0.1 to 8.0.2
@@ -0,1 +1,8 @@ | ||
## [8.0.2](https://github.com/harttle/liquidjs/compare/v8.0.1...v8.0.2) (2019-03-25) | ||
### Performance Improvements | ||
* use polymophism instead duck test ([82d7673](https://github.com/harttle/liquidjs/commit/82d7673)) | ||
## [8.0.1](https://github.com/harttle/liquidjs/compare/v8.0.0...v8.0.1) (2019-03-22) | ||
@@ -2,0 +9,0 @@ |
@@ -1,2 +0,2 @@ | ||
import Scope from './scope/scope'; | ||
import Context from './context/context'; | ||
import * as Types from './types'; | ||
@@ -22,3 +22,3 @@ import ITemplate from './template/itemplate'; | ||
renderFile(file: string, ctx?: object, opts?: LiquidOptions): Promise<string>; | ||
evalValue(str: string, scope: Scope): Promise<any>; | ||
evalValue(str: string, ctx: Context): Promise<any>; | ||
registerFilter(name: string, filter: FilterImpl): void; | ||
@@ -25,0 +25,0 @@ registerTag(name: string, tag: ITagImplOptions): void; |
@@ -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 r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function i(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var v=function(){return(v=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function d(o,s,u,a){return new(u||(u=Promise))(function(t,e){function n(t){try{i(a.next(t))}catch(t){e(t)}}function r(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(n,r)}i((a=a.apply(o,s||[])).next())})}function g(n,r){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=r.call(n,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 e=Object.prototype.toString;function p(t){return"[object String]"===e.call(t)}function o(t){return"function"==typeof t}function a(t){return u(t)?"":(t=s(t),String(t))}function s(t){return o(t.toLiquid)?s(t.toLiquid()):t}function u(t){return null==t}function m(t){return"[object Array]"===e.call(t)}function c(t,e){for(var n in t=t||{})if(t.hasOwnProperty(n)&&!1===e(t[n],n,t))break;return t}function l(t){return t[t.length-1]}function y(t){var e=typeof t;return null!==t&&("object"===e||"function"===e)}function w(t,e,n){void 0===n&&(n=1);for(var r=[],i=t;i<e;i+=n)r.push(i);return r}function f(t,e,n){void 0===n&&(n=" ");for(var r=e-(t=String(t)).length;0<r--;)t=n+t;return t}var h=function(){function t(){}return t.prototype.valueOf=function(){},t.prototype.liquidMethodMissing=function(t){},t}(),t=function(r){function t(t,e){var n=r.call(this,t.message)||this;return n.originalError=t,n.token=e,n}return i(t,r),t.prototype.update=function(){var i,o,t,s,e=this.originalError,n=(i=this.token,o=i.input.split("\n"),t=Math.max(i.line-2,1),s=Math.min(i.line+3,o.length),w(t,s+1).map(function(t){var e=t===i.line?">> ":" ",n=f(String(t),String(s).length),r=o[t-1];return""+e+n+"| "+r}).join("\n"));this.message=function(t,e){e.file&&(t+=", file:"+e.file);return t+=", line:"+e.line+", col:"+e.col}(e.message,this.token),this.stack=this.message+"\n"+n+"\n"+this.stack+"\nFrom "+e.stack},t}(Error),b=function(r){function t(t,e){var n=r.call(this,new Error(t),e)||this;return n.name="TokenizationError",r.prototype.update.call(n),n}return i(t,r),t}(t),n=function(r){function t(t,e){var n=r.call(this,t,e)||this;return n.name="ParseError",n.message=t.message,r.prototype.update.call(n),n}return i(t,r),t}(t),T=function(r){function t(t,e){var n=r.call(this,t,e.token)||this;return n.name="RenderError",n.message=t.message,r.prototype.update.call(n),n}return i(t,r),t}(t),x=function(n){function t(t){var e=n.call(this,t)||this;return e.resolvedHTML="",e.name="RenderBreakError",e.message=t+"",e}return i(t,n),t}(Error),k=function(n){function t(t){var e=n.call(this,t)||this;return e.name="AssertionError",e.message=t+"",e}return i(t,n),t}(Error);function E(t,e){if(!t)throw new k(e=e||"expect "+t+" to be true")}var q,S,O={root:["."],cache:!1,extname:"",dynamicPartials:!0,trimTagRight:!1,trimTagLeft:!1,trimOutputRight:!1,trimOutputLeft:!1,greedy:!0,tagDelimiterLeft:"{%",tagDelimiterRight:"%}",outputDelimiterLeft:"{{",outputDelimiterRight:"}}",strictFilters:!1,strictVariables:!1};function R(t){var e;return(t=t||{}).hasOwnProperty("root")&&(t.root=m(e=t.root)?e:p(e)?[e]:[]),t}function M(t){return v({},O,t)}(S=q||(q={}))[S.OUTPUT=0]="OUTPUT",S[S.STORE=1]="STORE";var L=q,D=function(){function t(t,e){void 0===t&&(t={}),this.contexts=[{}],this.blocks={},this.groups={},this.blockMode=L.OUTPUT,this.opts=M(e),this.environments=t}return t.prototype.getAll=function(){return[this.environments].concat(this.contexts).reduce(function(t,e){return v(t,e)},{})},t.prototype.get=function(s){return d(this,void 0,void 0,function(){var e,n,r,i,o;return g(this,function(t){switch(t.label){case 0:return[4,this.propertyAccessSeq(s)];case 1:for(e=t.sent(),n=this.findContextFor(e[0])||this.environments,r=0,i=e;r<i.length;r++)if(o=i[r],u(n=this.readProperty(n,o))&&this.opts.strictVariables)throw new TypeError("undefined variable: "+o);return[2,n]}})})},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){for(var e=this.contexts.length-1;0<=e;e--){var n=this.contexts[e];if(t in n)return n}return null},t.prototype.readProperty=function(t,e){return u(t)?t:(t=s(t))instanceof h?o(t[e])?t[e]():t.hasOwnProperty(e)?t[e]:t.liquidMethodMissing(e):"size"===e?u((n=t).size)&&(m(n)||p(n))?n.length:n.size:t[e];var n},t.prototype.propertyAccessSeq=function(a){return d(this,void 0,void 0,function(){function e(){r.length&&n.push(r),r=""}var n,r,i,o,s,u;return g(this,function(t){switch(t.label){case 0:a=String(a),n=[],r="",o=0,t.label=1;case 1:if(!(o<a.length))return[3,10];switch(a[o]){case"[":return[3,2];case".":return[3,7]}return[3,8];case 2:return e(),s=a[o+1],/['"]/.test(s)?(E(-1!==(i=a.indexOf(s,o+2)),"unbalanced "+s+": "+a),r=a.slice(o+2,i),e(),o=i+2,[3,6]):[3,3];case 3:return E(-1!==(i=function(t,e){for(var n=1,r=e;r<t.length;r++)if("["===t[r]&&n++,"]"===t[r]&&0===--n)return r;return-1}(a,o+1)),"unbalanced []: "+a),r=a.slice(o+1,i),/^[+-]?\d+$/.test(r)?[3,5]:(u=String,[4,this.get(r)]);case 4:r=u.apply(void 0,[t.sent()]),t.label=5;case 5:e(),o=i+1,t.label=6;case 6:return[3,9];case 7:return e(),o++,[3,9];case 8:r+=a[o],o++,t.label=9;case 9:return[3,1];case 10:if(e(),!n.length)throw new TypeError('invalid path:"'+a+'"');return[2,n]}})})},t}();var P=Object.freeze({ParseError:n,TokenizationError:b,RenderBreakError:x,AssertionError:k,Drop:h});var F={readFile:function(r){return d(this,void 0,void 0,function(){return g(this,function(t){return[2,new Promise(function(t,e){var n=new XMLHttpRequest;n.onload=function(){200<=n.status&&n.status<300?t(n.responseText):e(new Error(n.statusText))},n.onerror=function(){e(new Error("An error occurred whilst receiving the response."))},n.open("GET",r),n.send()})]})})},resolve:function(t,e,i){return t.length&&"/"!==l(t)&&(t+="/"),function(t,e){var n=document.createElement("base");n.href=t;var r=document.getElementsByTagName("head")[0];r.insertBefore(n,r.firstChild);var i=document.createElement("a");i.href=e;var o=i.href;return r.removeChild(n),o}(t,e).replace(/^(\w+:\/\/[^/]+)(\/[^?]+)/,function(t,e,n){var r=n.split("/").pop();return/\.\w+$/.test(r)?t:e+n+i})},exists:function(){return d(this,void 0,void 0,function(){return g(this,function(t){return[2,!0]})})}};var U,j,A=function(t,e,n,r,i){this.type="notset",this.col=r,this.line=n,this.raw=t,this.value=t,this.input=e,this.file=i},_=function(s){function t(t,e,n,r,i){var o=s.call(this,t,e,n,r,i)||this;return o.type="html",o.value=t,o}return i(t,s),t}(A),H=function(u){function t(t,e,n,r,i,o){var s=u.call(this,t,n,r,i,o)||this;return s.trimLeft="-"===e[0],s.trimRight="-"===l(e),s.value=e.slice(s.trimLeft?1:0,s.trimRight?-1:e.length).trim(),s}return i(t,u),t}(A),N=new RegExp(/'[^']*'/.source+"|"+/"[^"]*"/.source),z=new RegExp("(?:"+N.source+"|[^'\"])*"),Y=/[+-]?(?:\d+\.?\d*|\.?\d+)/,$=/[\w-]+[?]?/,I=new RegExp("\\[(?:"+N.source+"|[\\w-\\.]+)\\]"),C=new RegExp("(?:"+N.source+"|"+/true|false/.source+"|"+Y.source+")"),B=new RegExp($.source+"(?:\\."+$.source+"|"+I.source+")*"),V=new RegExp("(?:"+B.source+"|"+Y.source+")"),G=new RegExp("\\("+V.source+"\\.\\."+V.source+"\\)"),W=new RegExp("\\(("+V.source+")\\.\\.("+V.source+")\\)"),J=new RegExp("(?:"+B.source+"|"+C.source+"|"+G.source+")"),X=new RegExp("(?:"+$.source+")\\s*:\\s*(?:"+J.source+")"),K=new RegExp("("+$.source+")\\s*:\\s*("+J.source+")","g"),Q=new RegExp("^\\s*("+$.source+")\\s*([\\s\\S]*?)\\s*$"),Z=new RegExp("^"+N.source+"$"),tt=new RegExp("^"+W.source+"$"),et=[/\s+or\s+/,/\s+and\s+/,/==|!=|<=|>=|<|>|\s+contains\s+/],nt=function(a){function t(t,e,n,r,i,o){var s=a.call(this,t,e,n,r,i,o)||this;s.type="tag";var u=s.value.match(Q);if(!u)throw new b("illegal tag syntax",s);return s.name=u[1],s.args=u[2],s}return i(t,a),t}(H),rt=function(u){function t(t,e,n,r,i,o){var s=u.call(this,t,e,n,r,i,o)||this;return s.type="output",s}return i(t,u),t}(H);(j=U||(U={}))[j.HTML=0]="HTML",j[j.OUTPUT=1]="OUTPUT",j[j.TAG=2]="TAG";var it=function(){function t(t){this.options=M(t)}return t.prototype.tokenize=function(t,e){for(var n=[],r=this.options.tagDelimiterLeft,i=this.options.tagDelimiterRight,o=this.options.outputDelimiterLeft,s=this.options.outputDelimiterRight,u=0,a=1,c=U.HTML,l="",f=0,h=1,p=1;u<t.length;){if("\n"===t[u]&&(a++,f=u+1),c===U.HTML){if(t.substr(u,o.length)===o){l&&n.push(new _(l,t,h,p,e)),h=a,p=u-f+1,u+=(l=o).length,c=U.OUTPUT;continue}if(t.substr(u,r.length)===r){l&&n.push(new _(l,t,h,p,e)),h=a,p=u-f+1,u+=(l=r).length,c=U.TAG;continue}}else{if(c===U.OUTPUT&&t.substr(u,s.length)===s){l+=s,n.push(new rt(l,l.slice(o.length,-s.length),t,h,p,e)),l="",h=a,p=(u+=s.length)-f+1,c=U.HTML;continue}if(t.substr(u,i.length)===i){l+=i,n.push(new nt(l,l.slice(r.length,-i.length),t,h,p,e)),l="",h=a,p=(u+=i.length)-f+1,c=U.HTML;continue}}l+=t[u++]}if(c===U.HTML)return l&&n.push(new _(l,t,h,p,e)),function(s,u){u=v({greedy:!0},u);var a=!1;s.forEach(function(t,e){var n,r,i,o;i=t,o=u,!a&&("tag"===i.type?i.trimLeft||o.trimTagLeft:"output"===i.type?i.trimLeft||o.trimOutputLeft:void 0)&&function(t,e){if(t&&"html"===t.type){var n=e?/\s+$/g:/[\t\r ]*$/g;t.value=t.value.replace(n,"")}}(s[e-1],u.greedy),"tag"===t.type&&"raw"===t.name&&(a=!0),"tag"===t.type&&"endraw"===t.name&&(a=!1),n=t,r=u,!a&&("tag"===n.type?n.trimRight||r.trimTagRight:"output"===n.type?n.trimRight||r.trimOutputRight:void 0)&&function(t,e){if(t&&"html"===t.type){var n=e?/^\s+/g:/^[\t\r ]*\n?/g;t.value=t.value.replace(n,"")}}(s[e+1],u.greedy)})}(n,this.options),n;var d=c===U.OUTPUT?"output":"tag",g=16<l.length?l.slice(0,13)+"...":l;throw new b(d+' "'+g+'" not closed',new A(l,t,h,p,e))},t}(),ot=function(){function t(){}return t.prototype.renderTemplates=function(u,a){return d(this,void 0,void 0,function(){var e,n,r,i,o,s;return g(this,function(t){switch(t.label){case 0:E(a,"unable to evalTemplates: scope undefined"),e="",n=0,r=u,t.label=1;case 1:if(!(n<r.length))return[3,6];i=r[n],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("RenderBreakError"===(s=t.sent()).name)throw s.resolvedHTML=e,s;throw"RenderError"===s.name?s:new T(s,i);case 5:return n++,[3,1];case 6:return[2,e]}})})},t}();function st(t){return t&&o(t.equals)}var ut=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.equals=function(t){return p(t)||m(t)?0===t.length:!!y(t)&&0===Object.keys(t).length},e.prototype.gt=function(){return!1},e.prototype.geq=function(){return!1},e.prototype.lt=function(){return!1},e.prototype.leq=function(){return!1},e.prototype.valueOf=function(){return""},e}(h),at=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.equals=function(t){return!1===t||(!!u(t instanceof h?t.valueOf():t)||(p(t)?/^\s*$/.test(t):e.prototype.equals.call(this,t)))},t}(ut),ct=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.equals=function(t){return u(t instanceof h?t.valueOf():t)||t instanceof at},e.prototype.gt=function(){return!1},e.prototype.geq=function(){return!1},e.prototype.lt=function(){return!1},e.prototype.leq=function(){return!1},e.prototype.valueOf=function(){return null},e}(h),lt={"==":function(t,e){return st(t)?t.equals(e):st(e)?e.equals(t):t===e},"!=":function(t,e){return st(t)?!t.equals(e):st(e)?!e.equals(t):t!==e},">":function(t,e){return st(t)?t.gt(e):st(e)?e.lt(t):e<t},"<":function(t,e){return st(t)?t.lt(e):st(e)?e.gt(t):t<e},">=":function(t,e){return st(t)?t.geq(e):st(e)?e.leq(t):e<=t},"<=":function(t,e){return st(t)?t.leq(e):st(e)?e.geq(t):t<=e},contains:function(t,e){return!!t&&("function"==typeof t.indexOf&&-1<t.indexOf(e))},and:function(t,e){return dt(t)&&dt(e)},or:function(t,e){return dt(t)||dt(e)}};function ft(n,r){return d(this,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return[4,function f(h,p){return d(this,void 0,void 0,function(){var e,n,r,i,o,s,u,a,c,l;return g(this,function(t){switch(t.label){case 0:E(p,"unable to parseExp: scope undefined"),e=et,r=0,t.label=1;case 1:return r<e.length?(i=e[r],o=new RegExp("^("+z.source+")("+i.source+")("+z.source+")$"),(n=h.match(o))?[4,f(n[1],p)]:[3,4]):[3,5];case 2:return s=t.sent(),u=lt[n[2].trim()],[4,f(n[3],p)];case 3:return a=t.sent(),[2,u(s,a)];case 4:return r++,[3,1];case 5:return(n=h.match(tt))?[4,pt(n[1],p)]:[3,8];case 6:return c=t.sent(),[4,pt(n[2],p)];case 7:return l=t.sent(),[2,w(+c,+l+1)];case 8:return[2,ht(h,p)]}})})}(n,r)];case 1:return[2,(e=t.sent())instanceof h?e.valueOf():e]}})})}function ht(e,n){return d(this,void 0,void 0,function(){return g(this,function(t){return e?"true"===(e=e.trim())?[2,!0]:"false"===e?[2,!1]:"nil"===e||"null"===e?[2,new ct]:"empty"===e?[2,new ut]:"blank"===e?[2,new at]:isNaN(Number(e))?'"'!==e[0]&&"'"!==e[0]||e[0]!==l(e)?[2,n.get(e)]:[2,e.slice(1,-1)]:[2,Number(e)]:[2,null]})})}function pt(n,r){return d(this,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return[4,ht(n,r)];case 1:return[2,(e=t.sent())instanceof h?e.valueOf():e]}})})}function dt(t){return!gt(t)}function gt(t){return!1===t||null==t}var vt=function(){function c(){}return c.create=function(u,a){return d(this,void 0,void 0,function(){var e,n,r,i,o,s;return g(this,function(t){switch(t.label){case 0:e=new c,K.lastIndex=0,t.label=1;case 1:return(n=K.exec(u))?(r=n[1],i=n[2],o=e,s=r,[4,pt(i,a)]):[3,3];case 2:return o[s]=t.sent(),[3,1];case 3:return[2,e]}})})},c}(),mt=function(t){this.token=t},yt=function(s){function u(t,e,n){var r=s.call(this,t)||this;r.name=t.name;var i,o=u.impls[t.name];return E(o,"tag "+t.name+" not found"),r.impl=(i=o,Object.create(i)),r.impl.liquid=n,r.impl.parse&&r.impl.parse(t,e),r}return i(u,s),u.prototype.render=function(r){return d(this,void 0,void 0,function(){var e,n;return g(this,function(t){switch(t.label){case 0:return[4,vt.create(this.token.args,r)];case 1:return e=t.sent(),"function"!=typeof(n=this.impl).render?[2,""]:[4,n.render(r,e)];case 2:return[2,a(t.sent())]}})})},u.register=function(t,e){u.impls[t]=e},u.clear=function(){u.impls={}},u.impls={},u}(mt),wt=function(){function i(t,e,n){var r=i.impls[t];if(!r&&n)throw new TypeError("undefined filter: "+t);this.name=t,this.impl=r||function(t){return t},this.args=e}return i.prototype.render=function(l,f){return d(this,void 0,void 0,function(){var e,n,r,i,o,s,u,a,c;return g(this,function(t){switch(t.label){case 0:e=[],n=0,r=this.args,t.label=1;case 1:return n<r.length?m(i=r[n])?(s=(o=e).push,u=[i[0]],[4,pt(i[1],f)]):[3,3]:[3,6];case 2:return s.apply(o,[u.concat([t.sent()])]),[3,5];case 3:return c=(a=e).push,[4,pt(i,f)];case 4:c.apply(a,[t.sent()]),t.label=5;case 5:return n++,[3,1];case 6:return[2,this.impl.apply(null,[l].concat(e))]}})})},i.register=function(t,e){i.impls[t]=e},i.clear=function(){i.impls={}},i.impls={},i}(),bt=function(){function t(t,e){this.handlers={},this.stopRequested=!1,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 n=this.handlers[t];return"function"==typeof n&&(n(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}(),Tt=function(){function r(t,e){this.filters=[];var n=r.tokenize(t);this.strictFilters=e,this.initial=n[0],this.parseFilters(n,1)}return r.prototype.parseFilters=function(t,e){for(var n=e;n<t.length;)if("|"===t[n]){for(var r=++n;n<t.length&&"|"!==t[n];)n++;this.parseFilter(t,r,n)}else n++},r.prototype.parseFilter=function(t,e,n){for(var r,i,o=t[e],s=[],u=e+1;u<n+1;u++)u===n||","===t[u]?((r||i)&&s.push(r?[r,i]:i),i=r=void 0):":"===t[u]?(r=i,i=void 0):void 0===i&&(i=t[u]);this.filters.push(new wt(o,s,this.strictFilters))},r.prototype.value=function(i){return d(this,void 0,void 0,function(){var e,n,r;return g(this,function(t){switch(t.label){case 0:return[4,ft(this.initial,i)];case 1:e=t.sent(),n=0,r=this.filters,t.label=2;case 2:return n<r.length?[4,r[n].render(e,i)]:[3,5];case 3:e=t.sent(),t.label=4;case 4:return n++,[3,2];case 5:return[2,e]}})})},r.tokenize=function(t){for(var e=[],n=0;n<t.length;){var r=t[n];if('"'===r||"'"===r){var i=n;for(n+=2;n<t.length&&t[n-1]!==r;++n);e.push(t.slice(i,n))}else if(/\s/.test(r))n++;else if(/[|,:]/.test(r))e.push(t[n++]);else{for(i=n++;n<t.length&&!/[|,:\s]/.test(t[n]);++n);e.push(t.slice(i,n))}}return e},r}(),xt=function(r){function t(t,e){var n=r.call(this,t)||this;return n.value=new Tt(t.value,e),n}return i(t,r),t.prototype.render=function(e){return d(this,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return[4,this.value.value(e)];case 1:return[2,a(t.sent())]}})})},t}(mt),kt=function(n){function t(t){var e=n.call(this,t)||this;return e.str=t.value,e}return i(t,n),t.prototype.render=function(){return d(this,void 0,void 0,function(){return g(this,function(t){return[2,this.str]})})},t}(mt),Et=function(){function t(t){this.liquid=t}return t.prototype.parse=function(t){for(var e,n=[];e=t.shift();)n.push(this.parseToken(e,t));return n},t.prototype.parseToken=function(e,t){try{return"tag"===e.type?new yt(e,t,this.liquid):"output"===e.type?new xt(e,this.liquid.options.strictFilters):new kt(e)}catch(t){throw new n(t,e)}},t.prototype.parseStream=function(t){var n=this;return new bt(t,function(t,e){return n.parseToken(t,e)})},t}(),qt=new RegExp("("+$.source+")\\s*=([^]*)"),St={parse:function(t){var e=t.args.match(qt);E(e,"illegal token "+t.raw),this.key=e[1],this.value=e[2]},render:function(r){return d(this,void 0,void 0,function(){var e,n;return g(this,function(t){switch(t.label){case 0:return e=r.contexts[0],n=this.key,[4,this.liquid.evalValue(this.value,r)];case 1:return e[n]=t.sent(),[2]}})})}},Ot=function(n){function t(t){var e=n.call(this)||this;return e.i=0,e.length=t,e}return i(t,n),t.prototype.next=function(){this.i++},t.prototype.index0=function(){return this.i},t.prototype.index=function(){return this.i+1},t.prototype.first=function(){return 0===this.i},t.prototype.last=function(){return this.i===this.length-1},t.prototype.rindex=function(){return this.length-this.i},t.prototype.rindex0=function(){return this.length-this.i-1},t.prototype.valueOf=function(){return JSON.stringify(this)},t}(h),Rt=new RegExp("^("+$.source+")\\s+in\\s+("+J.source+")(?:\\s+"+X.source+")*(?:\\s+(reversed))?(?:\\s+"+X.source+")*$"),Mt={type:"block",parse:function(t,e){var n,r=this,i=Rt.exec(t.args);E(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 n=r.templates}).on("tag:else",function(){return n=r.elseTemplates}).on("tag:endfor",function(){return o.stop()}).on("template",function(t){return n.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});o.start()},render:function(f,h){return d(this,void 0,void 0,function(){var e,n,r,i,o,s,u,a,c,l;return g(this,function(t){switch(t.label){case 0:return[4,ft(this.collection,f)];case 1:if(m(e=t.sent())||(p(e)&&0<e.length?e=[e]:y(e)&&(e=Object.keys(e).map(function(t){return[t,e[t]]}))),!m(e)||!e.length)return[2,this.liquid.renderer.renderTemplates(this.elseTemplates,f)];n=h.offset||0,r=void 0===h.limit?e.length:h.limit,e=e.slice(n,n+r),this.reversed&&e.reverse(),i={forloop:new Ot(e.length)},f.push(i),o="",s=0,u=e,t.label=2;case 2:if(!(s<u.length))return[3,8];a=u[s],i[this.variable]=a,t.label=3;case 3:return t.trys.push([3,5,,6]),c=o,[4,this.liquid.renderer.renderTemplates(this.templates,f)];case 4:return o=c+t.sent(),[3,6];case 5:if("RenderBreakError"!==(l=t.sent()).name)throw l;return o+=l.resolvedHTML,"break"===l.message?[3,8]:[3,6];case 6:i.forloop.next(),t.label=7;case 7:return s++,[3,2];case 8:return f.pop(),[2,o]}})})}},Lt=new RegExp("("+$.source+")"),Dt={parse:function(t,e){var n=this,r=t.args.match(Lt);E(r,t.args+" not valid identifier"),this.variable=r[1],this.templates=[];var i=this.liquid.parser.parseStream(e);i.on("tag:endcapture",function(){return i.stop()}).on("template",function(t){return n.templates.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")}),i.start()},render:function(n){return d(this,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return[4,this.liquid.renderer.renderTemplates(this.templates,n)];case 1:return e=t.sent(),n.contexts[0][this.variable]=e,[2]}})})}},Pt={parse:function(t,e){var n=this;this.cond=t.args,this.cases=[],this.elseTemplates=[];var r=[],i=this.liquid.parser.parseStream(e).on("tag:when",function(t){n.cases.push({val:t.args,templates:r=[]})}).on("tag:else",function(){return r=n.elseTemplates}).on("tag:endcase",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(o){return d(this,void 0,void 0,function(){var e,n,r,i;return g(this,function(t){switch(t.label){case 0:e=0,t.label=1;case 1:return e<this.cases.length?[4,ft((n=this.cases[e]).val,o)]:[3,5];case 2:return r=t.sent(),[4,ft(this.cond,o)];case 3:if(i=t.sent(),r===i)return[2,this.liquid.renderer.renderTemplates(n.templates,o)];t.label=4;case 4:return e++,[3,1];case 5:return[2,this.liquid.renderer.renderTemplates(this.elseTemplates,o)]}})})}},Ft={parse:function(t,e){var n=this.liquid.parser.parseStream(e);n.on("token",function(t){"endcomment"===t.name&&n.stop()}).on("end",function(){throw new Error("tag "+t.raw+" not closed")}),n.start()}},Ut=/[^\s,]+/,jt=new RegExp("with\\s+("+J.source+")"),At={parse:function(t){var e=Ut.exec(t.args);e&&(this.staticValue=e[0]),(e=J.exec(t.args))&&(this.value=e[0]),(e=jt.exec(t.args))&&(this.with=e[1])},render:function(c,l){return d(this,void 0,void 0,function(){var e,n,r,i,o,s,u,a;return g(this,function(t){switch(t.label){case 0:return c.opts.dynamicPartials?Z.exec(this.value)?(n=this.value.slice(1,-1),[4,this.liquid.parseAndRender(n,c.getAll(),c.opts)]):[3,2]:[3,5];case 1:return e=t.sent(),[3,4];case 2:return[4,pt(this.value,c)];case 3:e=t.sent(),t.label=4;case 4:return[3,6];case 5:e=this.staticValue,t.label=6;case 6:return E(e,"cannot include with empty filename"),r=c.blocks,i=c.blockMode,c.blocks={},c.blockMode=L.OUTPUT,this.with?(o=l,s=e,[4,pt(this.with,c)]):[3,8];case 7:o[s]=t.sent(),t.label=8;case 8:return[4,this.liquid.getTemplate(e,c.opts)];case 9:return u=t.sent(),c.push(l),[4,this.liquid.renderer.renderTemplates(u,c)];case 10:return a=t.sent(),c.pop(l),c.blocks=r,c.blockMode=i,[2,a]}})})}},_t={parse:function(t){var e=t.args.match($);E(e,"illegal identifier "+t.args),this.variable=e[0]},render:function(t){var e=t.environments;return"number"!=typeof e[this.variable]&&(e[this.variable]=0),--e[this.variable]}},Ht=new RegExp("^(?:("+J.source+")\\s*:\\s*)?(.*)$"),Nt=new RegExp(J.source,"g"),zt={parse:function(t){var e=Ht.exec(t.args);E(e,"illegal tag: "+t.raw),this.group=e[1]||"";var n=e[2];for(this.candidates=[];e=Nt.exec(n);)this.candidates.push(e[0]);E(this.candidates.length,"empty candidates: "+t.raw)},render:function(s){return d(this,void 0,void 0,function(){var e,n,r,i,o;return g(this,function(t){switch(t.label){case 0:return[4,pt(this.group,s)];case 1:return e=t.sent(),n="cycle:"+e+":"+this.candidates.join(","),r=s.groups,void 0===(i=r[n])&&(i=r[n]=0),o=this.candidates[i],i=(i+1)%this.candidates.length,r[n]=i,[2,pt(o,s)]}})})}},Yt={parse:function(t,e){var n,r=this;this.branches=[],this.elseTemplates=[];var i=this.liquid.parser.parseStream(e).on("start",function(){return r.branches.push({cond:t.args,templates:n=[]})}).on("tag:elsif",function(t){r.branches.push({cond:t.args,templates:n=[]})}).on("tag:else",function(){return n=r.elseTemplates}).on("tag:endif",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(i){return d(this,void 0,void 0,function(){var e,n,r;return g(this,function(t){switch(t.label){case 0:e=0,n=this.branches,t.label=1;case 1:return e<n.length?[4,ft((r=n[e]).cond,i)]:[3,4];case 2:if(dt(t.sent()))return[2,this.liquid.renderer.renderTemplates(r.templates,i)];t.label=3;case 3:return e++,[3,1];case 4:return[2,this.liquid.renderer.renderTemplates(this.elseTemplates,i)]}})})}},$t={parse:function(t){var e=t.args.match($);E(e,"illegal identifier "+t.args),this.variable=e[0]},render:function(t){var e=t.environments;"number"!=typeof e[this.variable]&&(e[this.variable]=0);var n=e[this.variable];return e[this.variable]++,n}},It=/\S+/,Ct={parse:function(t,e){var n=It.exec(t.args);n&&(this.staticLayout=n[0]),(n=J.exec(t.args))&&(this.layout=n[0]),this.tpls=this.liquid.parser.parse(e)},render:function(s,u){return d(this,void 0,void 0,function(){var e,n,r,i,o;return g(this,function(t){switch(t.label){case 0:return s.opts.dynamicPartials?[4,pt(this.layout,s)]:[3,2];case 1:return n=t.sent(),[3,3];case 2:n=this.staticLayout,t.label=3;case 3:return E(e=n,"cannot apply layout with empty filename"),s.blockMode=L.STORE,[4,this.liquid.renderer.renderTemplates(this.tpls,s)];case 4:return r=t.sent(),void 0===s.blocks[""]&&(s.blocks[""]=r),[4,this.liquid.getTemplate(e,s.opts)];case 5:return i=t.sent(),s.push(u),s.blockMode=L.OUTPUT,[4,this.liquid.renderer.renderTemplates(i,s)];case 6:return o=t.sent(),s.pop(u),[2,o]}})})}},Bt={parse:function(t,e){var n=this,r=/\w+/.exec(t.args);this.block=r?r[0]:"",this.tpls=[];var i=this.liquid.parser.parseStream(e).on("tag:endblock",function(){return i.stop()}).on("template",function(t){return n.tpls.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});i.start()},render:function(i){return d(this,void 0,void 0,function(){var e,n,r;return g(this,function(t){switch(t.label){case 0:return void 0===(e=i.blocks[this.block])?[3,1]:(r=e,[3,3]);case 1:return[4,this.liquid.renderer.renderTemplates(this.tpls,i)];case 2:r=t.sent(),t.label=3;case 3:return n=r,i.blockMode===L.STORE?(i.blocks[this.block]=n,[2,""]):[2,n]}})})}},Vt={parse:function(t,e){var n=this;this.tokens=[];var r=this.liquid.parser.parseStream(e);r.on("token",function(t){"endraw"===t.name?r.stop():n.tokens.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")}),r.start()},render:function(){return this.tokens.map(function(t){return t.raw}).join("")}},Gt=function(r){function t(t,e){var n=r.call(this,t)||this;return n.length=t,n.cols=e,n}return i(t,r),t.prototype.row=function(){return Math.floor(this.i/this.cols)+1},t.prototype.col0=function(){return this.i%this.cols},t.prototype.col=function(){return this.col0()+1},t.prototype.col_first=function(){return 0===this.col0()},t.prototype.col_last=function(){return this.col()===this.cols},t}(Ot),Wt=new RegExp("^("+$.source+")\\s+in\\s+("+J.source+")(?:\\s+"+X.source+")*$"),Jt={assign:St,for:Mt,capture:Dt,case:Pt,comment:Ft,include:At,decrement:_t,increment:$t,cycle:zt,if:Yt,layout:Ct,block:Bt,raw:Vt,tablerow:{parse:function(t,e){var n,r=this,i=Wt.exec(t.args);E(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 n=r.templates}).on("tag:endtablerow",function(){return o.stop()}).on("template",function(t){return n.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});o.start()},render:function(l,f){return d(this,void 0,void 0,function(){var e,n,r,i,o,s,u,a,c;return g(this,function(t){switch(t.label){case 0:return[4,ft(this.collection,l)];case 1:e=t.sent()||[],n=f.offset||0,r=void 0===f.limit?e.length:f.limit,e=e.slice(n,n+r),i=f.cols||e.length,o=new Gt(e.length,i),s={tablerowloop:o},l.push(s),u="",a=0,t.label=2;case 2:return a<e.length?(s[this.variable]=e[a],0===o.col0()&&(1!==o.row()&&(u+="</tr>"),u+='<tr class="row'+o.row()+'">'),u+='<td class="col'+o.col()+'">',c=u,[4,this.liquid.renderer.renderTemplates(this.templates,l)]):[3,5];case 3:u=c+t.sent(),u+="</td>",t.label=4;case 4:return a++,o.next(),[3,2];case 5:return e.length&&(u+="</tr>"),l.pop(s),[2,u]}})})}},unless:{parse:function(t,e){var n,r=this;this.templates=[],this.elseTemplates=[];var i=this.liquid.parser.parseStream(e).on("start",function(){n=r.templates,r.cond=t.args}).on("tag:else",function(){return n=r.elseTemplates}).on("tag:endunless",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(e){return d(this,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return[4,ft(this.cond,e)];case 1:return[2,gt(t.sent())?this.liquid.renderer.renderTemplates(this.templates,e):this.liquid.renderer.renderTemplates(this.elseTemplates,e)]}})})}},break:{render:function(){return d(this,void 0,void 0,function(){return g(this,function(t){throw new x("break")})})}},continue:{render:function(){return d(this,void 0,void 0,function(){return g(this,function(t){throw new x("continue")})})}}},Xt={"&":"&","<":"<",">":">",'"':""","'":"'"},Kt={"&":"&","<":"<",">":">",""":'"',"'":"'"};function Qt(t){return String(t).replace(/&|<|>|"|'/g,function(t){return Xt[t]})}var Zt={escape:Qt,escape_once:function(t){return Qt(String(t).replace(/&(amp|lt|gt|#34|#39);/g,function(t){return Kt[t]}))},newline_to_br:function(t){return t.replace(/\n/g,"<br />")},strip_html:function(t){return t.replace(/<script.*?<\/script>|<!--.*?-->|<style.*?<\/style>|<.*?>/g,"")}},te={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)},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,n){return String(t).split(e).join(n)},replace_first:function(t,e,n){return String(t).replace(e,n)},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,n){return void 0===e&&(e=50),void 0===n&&(n="..."),(t=String(t)).length<=e?t:t.substr(0,e-n.length)+n},truncatewords:function(t,e,n){void 0===e&&(e=15),void 0===n&&(n="...");var r=t.split(/\s+/),i=r.slice(0,e).join(" ");return r.length>=e&&(i+=n),i}},ee={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:function(t,e){return t-e},modulo:function(t,e){return t%e},round:function(t,e){void 0===e&&(e=0);var n=Math.pow(10,e);return Math.round(t*n)/n},plus:function(t,e){return Number(t)+Number(e)},times:function(t,e){return t*e}},ne={url_decode:function(t){return t.split("+").map(decodeURIComponent).join(" ")},url_encode:function(t){return t.split(" ").map(encodeURIComponent).join("+")}},re={join:function(t,e){return t.join(void 0===e?" ":e)},last:function(t){return l(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},concat:function(t,e){return Array.prototype.concat.call(t,e)},slice:function(t,e,n){return void 0===n&&(n=1),t.slice(e,e+n)},uniq:function(t){var e={};return(t||[]).filter(function(t){return!e.hasOwnProperty(String(t))&&(e[String(t)]=!0)})}},ie=["January","February","March","April","May","June","July","August","September","October","November","December"],oe=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],se=ie.map(ce),ue=oe.map(ce),ae={1:"st",2:"nd",3:"rd",default:"th"};function ce(t){return t.slice(0,3)}var le={daysInMonth:function(t){return[31,le.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31]},getDayOfYear:function(t){for(var e=0,n=0;n<t.getMonth();++n)e+=le.daysInMonth(t)[n];return e+t.getDate()},getWeekOfYear:function(t,e){var n=this.getDayOfYear(t)+(e-t.getDay()),r=7-new Date(t.getFullYear(),0,1).getDay()+e;return f(String(Math.floor((n-r)/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(),n=parseInt(e.slice(-1));return ae[n]||ae.default},century:function(t){return parseInt(t.getFullYear().toString().substring(0,2),10)}},fe={a:function(t){return ue[t.getDay()]},A:function(t){return oe[t.getDay()]},b:function(t){return se[t.getMonth()]},B:function(t){return ie[t.getMonth()]},c:function(t){return t.toLocaleString()},C:function(t){return le.century(t)},d:function(t){return f(t.getDate(),2,"0")},e:function(t){return f(t.getDate(),2)},H:function(t){return f(t.getHours(),2,"0")},I:function(t){return f(String(t.getHours()%12||12),2,"0")},j:function(t){return f(le.getDayOfYear(t),3,"0")},k:function(t){return f(t.getHours(),2)},l:function(t){return f(String(t.getHours()%12||12),2)},L:function(t){return f(t.getMilliseconds(),3,"0")},m:function(t){return f(t.getMonth()+1,2,"0")},M:function(t){return f(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 le.getSuffix(t)},s:function(t){return Math.round(t.valueOf()/1e3)},S:function(t){return f(t.getSeconds(),2,"0")},u:function(t){return t.getDay()||7},U:function(t){return le.getWeekOfYear(t,0)},w:function(t){return t.getDay()},W:function(t){return le.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?"-":"+")+f(String(Math.abs(e)),4,"0")},"%":function(){return"%"}};fe.h=fe.b,fe.N=fe.L;var he=v({},Zt,te,ee,ne,{date:function(t,e){var n,r=t;return"now"===t?r=new Date:p(t)&&(r=new Date(t)),(n=r)instanceof Date&&!isNaN(n.getTime())?function(t,e){for(var n="",r=e;;){var i=/%./g,o=i.exec(r);if(!o)return n+r;n+=r.slice(0,i.lastIndex-2),r=r.slice(i.lastIndex);var s=o[0].charAt(1),u=fe[s];n+=u?u(t):"%"+s}}(r,e):t}},{default:function(t,e){return dt(t)?t:e}},re);return function(){function e(t){void 0===t&&(t={});var n=this;this.cache={},this.options=M(R(t)),this.parser=new Et(this),this.renderer=new ot,this.tokenizer=new it(this.options),c(Jt,function(t,e){return n.registerTag(e,t)}),c(he,function(t,e){return n.registerFilter(e,t)})}return e.prototype.parse=function(t,e){var n=this.tokenizer.tokenize(t,e);return this.parser.parse(n)},e.prototype.render=function(t,e,n){var r=v({},this.options,R(n)),i=new D(e,r);return this.renderer.renderTemplates(t,i)},e.prototype.parseAndRender=function(n,r,i){return d(this,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return[4,this.parse(n)];case 1:return e=t.sent(),[2,this.render(e,r,i)]}})})},e.prototype.getTemplate=function(f,h){return d(this,void 0,void 0,function(){var e,n,r,i,o,s,u,a,c,l=this;return g(this,function(t){switch(t.label){case 0:e=R(h),n=e.root?e.root.concat(this.options.root):this.options.root,r=n.map(function(t){return F.resolve(t,f,l.options.extname)}),i=0,o=r,t.label=1;case 1:return i<o.length?(s=o[i],[4,F.exists(s)]):[3,5];case 2:return t.sent()?this.options.cache&&this.cache[s]?[2,this.cache[s]]:(a=this.parse,[4,F.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 "'+n+'"',c.code="ENOENT",c}})})},e.prototype.renderFile=function(r,i,o){return d(this,void 0,void 0,function(){var e,n;return g(this,function(t){switch(t.label){case 0:return e=R(o),[4,this.getTemplate(r,e)];case 1:return n=t.sent(),[2,this.render(n,i,o)]}})})},e.prototype.evalValue=function(t,e){return new Tt(t,this.options.strictFilters).value(e)},e.prototype.registerFilter=function(t,e){return wt.register(t,e)},e.prototype.registerTag=function(t,e){return yt.register(t,e)},e.prototype.plugin=function(t){return t.call(this,e)},e.prototype.express=function(){var i=this;return function(t,e,n){var r={root:this.root};i.renderFile(t,e,r).then(function(t){return n(null,t)},n)}},(e.default=e).isTruthy=dt,e.isFalsy=gt,e.evalExp=ft,e.evalValue=pt,e.Types=P,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 r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function i(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var m=function(){return(m=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};function d(s,o,u,a){return new(u||(u=Promise))(function(t,e){function n(t){try{i(a.next(t))}catch(t){e(t)}}function r(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(n,r)}i((a=a.apply(s,o||[])).next())})}function g(n,r){var i,s,o,t,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[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,s&&(o=2&e[0]?s.return:e[0]?s.throw||((o=s.return)&&o.call(s),0):s.next)&&!(o=o.call(s,e[1])).done)return o;switch(s=0,o&&(e=[2&e[0],o.value]),e[0]){case 0:case 1:o=e;break;case 4:return u.label++,{value:e[1],done:!1};case 5:u.label++,s=e[1],e=[0];continue;case 7:e=u.ops.pop(),u.trys.pop();continue;default:if(!(o=0<(o=u.trys).length&&o[o.length-1])&&(6===e[0]||2===e[0])){u=0;continue}if(3===e[0]&&(!o||e[1]>o[0]&&e[1]<o[3])){u.label=e[1];break}if(6===e[0]&&u.label<o[1]){u.label=o[1],o=e;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(e);break}o[2]&&u.ops.pop(),u.trys.pop();continue}e=r.call(n,u)}catch(t){e=[6,t],s=0}finally{i=o=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,t])}}}var e=Object.prototype.toString;function p(t){return"[object String]"===e.call(t)}function u(t){return"function"==typeof t}function a(t){return c(t)?"":(t=s(t),String(t))}function s(t){return u(t.toLiquid)?s(t.toLiquid()):t}function c(t){return null==t}function v(t){return"[object Array]"===e.call(t)}function o(t,e){for(var n in t=t||{})if(t.hasOwnProperty(n)&&!1===e(t[n],n,t))break;return t}function h(t){return t[t.length-1]}function w(t){var e=typeof t;return null!==t&&("object"===e||"function"===e)}function y(t,e,n){void 0===n&&(n=1);for(var r=[],i=t;i<e;i+=n)r.push(i);return r}function l(t,e,n){void 0===n&&(n=" ");for(var r=e-(t=String(t)).length;0<r--;)t=n+t;return t}var f=function(){function t(){}return t.prototype.valueOf=function(){},t.prototype.liquidMethodMissing=function(t){},t}(),t=function(r){function t(t,e){var n=r.call(this,t.message)||this;return n.originalError=t,n.token=e,n}return i(t,r),t.prototype.update=function(){var i,s,t,o,e=this.originalError,n=(i=this.token,s=i.input.split("\n"),t=Math.max(i.line-2,1),o=Math.min(i.line+3,s.length),y(t,o+1).map(function(t){var e=t===i.line?">> ":" ",n=l(String(t),String(o).length),r=s[t-1];return""+e+n+"| "+r}).join("\n"));this.message=function(t,e){e.file&&(t+=", file:"+e.file);return t+=", line:"+e.line+", col:"+e.col}(e.message,this.token),this.stack=this.message+"\n"+n+"\n"+this.stack+"\nFrom "+e.stack},t}(Error),b=function(r){function t(t,e){var n=r.call(this,new Error(t),e)||this;return n.name="TokenizationError",r.prototype.update.call(n),n}return i(t,r),t}(t),n=function(r){function t(t,e){var n=r.call(this,t,e)||this;return n.name="ParseError",n.message=t.message,r.prototype.update.call(n),n}return i(t,r),t}(t),T=function(r){function t(t,e){var n=r.call(this,t,e.token)||this;return n.name="RenderError",n.message=t.message,r.prototype.update.call(n),n}return i(t,r),t}(t),k=function(n){function t(t){var e=n.call(this,t)||this;return e.resolvedHTML="",e.name="RenderBreakError",e.message=t+"",e}return i(t,n),t}(Error),E=function(n){function t(t){var e=n.call(this,t)||this;return e.name="AssertionError",e.message=t+"",e}return i(t,n),t}(Error);function x(t,e){if(!t)throw new E(e=e||"expect "+t+" to be true")}var q,S,O={root:["."],cache:!1,extname:"",dynamicPartials:!0,trimTagRight:!1,trimTagLeft:!1,trimOutputRight:!1,trimOutputLeft:!1,greedy:!0,tagDelimiterLeft:"{%",tagDelimiterRight:"%}",outputDelimiterLeft:"{{",outputDelimiterRight:"}}",strictFilters:!1,strictVariables:!1};function R(t){var e;return(t=t||{}).hasOwnProperty("root")&&(t.root=v(e=t.root)?e:p(e)?[e]:[]),t}function M(t){return m({},O,t)}(S=q||(q={}))[S.OUTPUT=0]="OUTPUT",S[S.STORE=1]="STORE";var L=q,P=function(){function t(t,e){void 0===t&&(t={}),this.scopes=[{}],this.blocks={},this.groups={},this.blockMode=L.OUTPUT,this.opts=M(e),this.environments=t}return t.prototype.getAll=function(){return[this.environments].concat(this.scopes).reduce(function(t,e){return m(t,e)},{})},t.prototype.get=function(o){return d(this,void 0,void 0,function(){var e,n,r,i,s;return g(this,function(t){switch(t.label){case 0:return[4,this.parseProp(o)];case 1:for(e=t.sent(),n=this.findScope(e[0])||this.environments,r=0,i=e;r<i.length;r++)if(s=i[r],c(n=this.readProperty(n,s))&&this.opts.strictVariables)throw new TypeError("undefined variable: "+s);return[2,n]}})})},t.prototype.push=function(t){return this.scopes.push(t)},t.prototype.pop=function(e){if(!arguments.length)return this.scopes.pop();var t=this.scopes.findIndex(function(t){return t===e});if(-1===t)throw new TypeError("scope not found, cannot pop");return this.scopes.splice(t,1)[0]},t.prototype.findScope=function(t){for(var e=this.scopes.length-1;0<=e;e--){var n=this.scopes[e];if(t in n)return n}return null},t.prototype.readProperty=function(t,e){return c(t)?t:(t=s(t))instanceof f?u(t[e])?t[e]():t.hasOwnProperty(e)?t[e]:t.liquidMethodMissing(e):"size"===e?c((n=t).size)&&(v(n)||p(n))?n.length:n.size:t[e];var n},t.prototype.parseProp=function(a){return d(this,void 0,void 0,function(){function e(){r.length&&n.push(r),r=""}var n,r,i,s,o,u;return g(this,function(t){switch(t.label){case 0:a=String(a),n=[],r="",s=0,t.label=1;case 1:if(!(s<a.length))return[3,10];switch(a[s]){case"[":return[3,2];case".":return[3,7]}return[3,8];case 2:return e(),o=a[s+1],/['"]/.test(o)?(x(-1!==(i=a.indexOf(o,s+2)),"unbalanced "+o+": "+a),r=a.slice(s+2,i),e(),s=i+2,[3,6]):[3,3];case 3:return x(-1!==(i=function(t,e){for(var n=1,r=e;r<t.length;r++)if("["===t[r]&&n++,"]"===t[r]&&0===--n)return r;return-1}(a,s+1)),"unbalanced []: "+a),r=a.slice(s+1,i),/^[+-]?\d+$/.test(r)?[3,5]:(u=String,[4,this.get(r)]);case 4:r=u.apply(void 0,[t.sent()]),t.label=5;case 5:e(),s=i+1,t.label=6;case 6:return[3,9];case 7:return e(),s++,[3,9];case 8:r+=a[s++],t.label=9;case 9:return[3,1];case 10:if(e(),!n.length)throw new TypeError('invalid path:"'+a+'"');return[2,n]}})})},t}();var D=Object.freeze({ParseError:n,TokenizationError:b,RenderBreakError:k,AssertionError:E,Drop:f});var F={readFile:function(r){return d(this,void 0,void 0,function(){return g(this,function(t){return[2,new Promise(function(t,e){var n=new XMLHttpRequest;n.onload=function(){200<=n.status&&n.status<300?t(n.responseText):e(new Error(n.statusText))},n.onerror=function(){e(new Error("An error occurred whilst receiving the response."))},n.open("GET",r),n.send()})]})})},resolve:function(t,e,i){return t.length&&"/"!==h(t)&&(t+="/"),function(t,e){var n=document.createElement("base");n.href=t;var r=document.getElementsByTagName("head")[0];r.insertBefore(n,r.firstChild);var i=document.createElement("a");i.href=e;var s=i.href;return r.removeChild(n),s}(t,e).replace(/^(\w+:\/\/[^/]+)(\/[^?]+)/,function(t,e,n){var r=n.split("/").pop();return/\.\w+$/.test(r)?t:e+n+i})},exists:function(){return d(this,void 0,void 0,function(){return g(this,function(t){return[2,!0]})})}},U=function(t,e,n,r,i){this.trimLeft=!1,this.trimRight=!1,this.type="notset",this.col=r,this.line=n,this.raw=t,this.value=t,this.input=e,this.file=i},j=function(f){function t(t,e,n,r,i,s,o,u){var a=f.call(this,t,n,r,i,u)||this,c="-"===e[0],l="-"===h(e);return a.value=e.slice(c?1:0,l?-1:e.length).trim(),a.trimLeft=c||s,a.trimRight=l||o,a}return i(t,f),t}(U),_=new RegExp(/'[^']*'/.source+"|"+/"[^"]*"/.source),A=new RegExp("(?:"+_.source+"|[^'\"])*"),H=/[+-]?(?:\d+\.?\d*|\.?\d+)/,N=/[\w-]+[?]?/,z=new RegExp("\\[(?:"+_.source+"|[\\w-\\.]+)\\]"),Y=new RegExp("(?:"+_.source+"|"+/true|false/.source+"|"+H.source+")"),$=new RegExp(N.source+"(?:\\."+N.source+"|"+z.source+")*"),I=new RegExp("(?:"+$.source+"|"+H.source+")"),C=new RegExp("\\("+I.source+"\\.\\."+I.source+"\\)"),B=new RegExp("\\(("+I.source+")\\.\\.("+I.source+")\\)"),V=new RegExp("(?:"+$.source+"|"+Y.source+"|"+C.source+")"),G=new RegExp("(?:"+N.source+")\\s*:\\s*(?:"+V.source+")"),W=new RegExp("("+N.source+")\\s*:\\s*("+V.source+")","g"),J=new RegExp("^\\s*("+N.source+")\\s*([\\s\\S]*?)\\s*$"),X=new RegExp("^"+_.source+"$"),K=new RegExp("^"+B.source+"$"),Q=[/\s+or\s+/,/\s+and\s+/,/==|!=|<=|>=|<|>|\s+contains\s+/],Z=function(c){function t(t,e,n,r,i,s,o){var u=c.call(this,t,e,n,r,i,s.trimTagLeft,s.trimTagRight,o)||this;u.type="tag";var a=u.value.match(J);if(!a)throw new b("illegal tag syntax",u);return u.name=a[1],u.args=a[2],u}return i(t,c),t.is=function(t){return"tag"===t.type},t}(j),tt=function(o){function t(t,e,n,r,i){var s=o.call(this,t,e,n,r,i)||this;return s.type="html",s.value=t,s}return i(t,o),t.is=function(t){return"html"===t.type},t}(U);function et(t,e){if(t&&tt.is(t)){var n=e?/\s+$/g:/[\t\r ]*$/g;t.value=t.value.replace(n,"")}}function nt(t,e){if(t&&tt.is(t)){var n=e?/^\s+/g:/^[\t\r ]*\n?/g;t.value=t.value.replace(n,"")}}var rt,it,st=function(a){function t(t,e,n,r,i,s,o){var u=a.call(this,t,e,n,r,i,s.trimOutputLeft,s.trimOutputRight,o)||this;return u.type="output",u}return i(t,a),t.is=function(t){return"output"===t.type},t}(j);(it=rt||(rt={}))[it.HTML=0]="HTML",it[it.OUTPUT=1]="OUTPUT",it[it.TAG=2]="TAG";var ot=function(){function t(t){this.options=M(t)}return t.prototype.tokenize=function(t,e){for(var n=[],r=this.options,i=r.tagDelimiterLeft,s=r.tagDelimiterRight,o=r.outputDelimiterLeft,u=r.outputDelimiterRight,a=0,c=1,l=rt.HTML,f="",h=0,p=1,d=1;a<t.length;){if("\n"===t[a]&&(c++,h=a+1),l===rt.HTML){if(t.substr(a,o.length)===o){f&&n.push(new tt(f,t,p,d,e)),p=c,d=a-h+1,a+=(f=o).length,l=rt.OUTPUT;continue}if(t.substr(a,i.length)===i){f&&n.push(new tt(f,t,p,d,e)),p=c,d=a-h+1,a+=(f=i).length,l=rt.TAG;continue}}else{if(l===rt.OUTPUT&&t.substr(a,u.length)===u){f+=u,n.push(new st(f,f.slice(o.length,-u.length),t,p,d,this.options,e)),f="",p=c,d=(a+=u.length)-h+1,l=rt.HTML;continue}if(t.substr(a,s.length)===s){f+=s,n.push(new Z(f,f.slice(i.length,-s.length),t,p,d,this.options,e)),f="",p=c,d=(a+=s.length)-h+1,l=rt.HTML;continue}}f+=t[a++]}if(l===rt.HTML)return f&&n.push(new tt(f,t,p,d,e)),function(t,e){e=m({greedy:!0},e);for(var n=!1,r=0;r<t.length;r++){var i=t[r];!n&&i.trimLeft&&et(t[r-1],e.greedy),Z.is(i)&&("raw"===i.name?n=!0:"endraw"===i.name&&(n=!1)),!n&&i.trimRight&&nt(t[r+1],e.greedy)}}(n,this.options),n;var g=l===rt.OUTPUT?"output":"tag",v=16<f.length?f.slice(0,13)+"...":f;throw new b(g+' "'+v+'" not closed',new U(f,t,p,d,e))},t}(),ut=function(){function t(){}return t.prototype.renderTemplates=function(u,a){return d(this,void 0,void 0,function(){var e,n,r,i,s,o;return g(this,function(t){switch(t.label){case 0:x(a,"unable to evalTemplates: context undefined"),e="",n=0,r=u,t.label=1;case 1:if(!(n<r.length))return[3,6];i=r[n],t.label=2;case 2:return t.trys.push([2,4,,5]),s=e,[4,i.render(a)];case 3:return e=s+t.sent(),[3,5];case 4:if("RenderBreakError"===(o=t.sent()).name)throw o.resolvedHTML=e,o;throw"RenderError"===o.name?o:new T(o,i);case 5:return n++,[3,1];case 6:return[2,e]}})})},t}();function at(t){return t&&u(t.equals)}var ct=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.equals=function(t){return p(t)||v(t)?0===t.length:!!w(t)&&0===Object.keys(t).length},e.prototype.gt=function(){return!1},e.prototype.geq=function(){return!1},e.prototype.lt=function(){return!1},e.prototype.leq=function(){return!1},e.prototype.valueOf=function(){return""},e}(f),lt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.equals=function(t){return!1===t||(!!c(t instanceof f?t.valueOf():t)||(p(t)?/^\s*$/.test(t):e.prototype.equals.call(this,t)))},t}(ct),ft=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.equals=function(t){return c(t instanceof f?t.valueOf():t)||t instanceof lt},e.prototype.gt=function(){return!1},e.prototype.geq=function(){return!1},e.prototype.lt=function(){return!1},e.prototype.leq=function(){return!1},e.prototype.valueOf=function(){return null},e}(f),ht={"==":function(t,e){return at(t)?t.equals(e):at(e)?e.equals(t):t===e},"!=":function(t,e){return at(t)?!t.equals(e):at(e)?!e.equals(t):t!==e},">":function(t,e){return at(t)?t.gt(e):at(e)?e.lt(t):e<t},"<":function(t,e){return at(t)?t.lt(e):at(e)?e.gt(t):t<e},">=":function(t,e){return at(t)?t.geq(e):at(e)?e.leq(t):e<=t},"<=":function(t,e){return at(t)?t.leq(e):at(e)?e.geq(t):t<=e},contains:function(t,e){return!(!t||!u(t.indexOf))&&-1<t.indexOf(e)},and:function(t,e){return vt(t)&&vt(e)},or:function(t,e){return vt(t)||vt(e)}};function pt(n,r){return d(this,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return[4,function f(h,p){return d(this,void 0,void 0,function(){var e,n,r,i,s,o,u,a,c,l;return g(this,function(t){switch(t.label){case 0:x(p,"unable to parseExp: scope undefined"),e=Q,r=0,t.label=1;case 1:return r<e.length?(i=e[r],s=new RegExp("^("+A.source+")("+i.source+")("+A.source+")$"),(n=h.match(s))?[4,f(n[1],p)]:[3,4]):[3,5];case 2:return o=t.sent(),u=ht[n[2].trim()],[4,f(n[3],p)];case 3:return a=t.sent(),[2,u(o,a)];case 4:return r++,[3,1];case 5:return(n=h.match(K))?[4,gt(n[1],p)]:[3,8];case 6:return c=t.sent(),[4,gt(n[2],p)];case 7:return l=t.sent(),[2,y(+c,+l+1)];case 8:return[2,dt(h,p)]}})})}(n,r)];case 1:return[2,(e=t.sent())instanceof f?e.valueOf():e]}})})}function dt(e,n){return d(this,void 0,void 0,function(){return g(this,function(t){return e?"true"===(e=e.trim())?[2,!0]:"false"===e?[2,!1]:"nil"===e||"null"===e?[2,new ft]:"empty"===e?[2,new ct]:"blank"===e?[2,new lt]:isNaN(Number(e))?'"'!==e[0]&&"'"!==e[0]||e[0]!==h(e)?[2,n.get(e)]:[2,e.slice(1,-1)]:[2,Number(e)]:[2,null]})})}function gt(n,r){return d(this,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return[4,dt(n,r)];case 1:return[2,(e=t.sent())instanceof f?e.valueOf():e]}})})}function vt(t){return!mt(t)}function mt(t){return!1===t||null==t}var wt=function(){function c(){}return c.create=function(u,a){return d(this,void 0,void 0,function(){var e,n,r,i,s,o;return g(this,function(t){switch(t.label){case 0:e=new c,W.lastIndex=0,t.label=1;case 1:return(n=W.exec(u))?(r=n[1],i=n[2],s=e,o=r,[4,gt(i,a)]):[3,3];case 2:return s[o]=t.sent(),[3,1];case 3:return[2,e]}})})},c}(),yt=function(t){this.token=t},bt=function(s){function o(t,e,n){var r=s.call(this,t)||this;r.name=t.name;var i=o.impls[t.name];return x(i,"tag "+t.name+" not found"),r.impl=Object.create(i),r.impl.liquid=n,r.impl.parse&&r.impl.parse(t,e),r}return i(o,s),o.prototype.render=function(s){return d(this,void 0,void 0,function(){var e,n,r,i;return g(this,function(t){switch(t.label){case 0:return[4,wt.create(this.token.args,s)];case 1:return e=t.sent(),u((n=this.impl).render)?(i=a,[4,n.render(s,e)]):[3,3];case 2:return r=i.apply(void 0,[t.sent()]),[3,4];case 3:r="",t.label=4;case 4:return[2,r]}})})},o.register=function(t,e){o.impls[t]=e},o.clear=function(){o.impls={}},o.impls={},o}(yt),Tt=function(){function i(t,e,n){var r=i.impls[t];if(!r&&n)throw new TypeError("undefined filter: "+t);this.name=t,this.impl=r||function(t){return t},this.args=e}return i.prototype.render=function(l,f){return d(this,void 0,void 0,function(){var e,n,r,i,s,o,u,a,c;return g(this,function(t){switch(t.label){case 0:e=[],n=0,r=this.args,t.label=1;case 1:return n<r.length?v(i=r[n])?(o=(s=e).push,u=[i[0]],[4,gt(i[1],f)]):[3,3]:[3,6];case 2:return o.apply(s,[u.concat([t.sent()])]),[3,5];case 3:return c=(a=e).push,[4,gt(i,f)];case 4:c.apply(a,[t.sent()]),t.label=5;case 5:return n++,[3,1];case 6:return[2,this.impl.apply(null,[l].concat(e))]}})})},i.register=function(t,e){i.impls[t]=e},i.clear=function(){i.impls={}},i.impls={},i}(),kt=function(){function t(t,e){this.handlers={},this.stopRequested=!1,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 n=this.handlers[t];return!!n&&(n(e),!0)},t.prototype.start=function(){var t;for(this.trigger("start");!this.stopRequested&&(t=this.tokens.shift());)if(!(this.trigger("token",t)||Z.is(t)&&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}(),Et=function(){function r(t,e){this.filters=[];var n=r.tokenize(t);this.strictFilters=e,this.initial=n[0],this.parseFilters(n,1)}return r.prototype.parseFilters=function(t,e){for(var n=e;n<t.length;)if("|"===t[n]){for(var r=++n;n<t.length&&"|"!==t[n];)n++;this.parseFilter(t,r,n)}else n++},r.prototype.parseFilter=function(t,e,n){for(var r,i,s=t[e],o=[],u=e+1;u<n+1;u++)u===n||","===t[u]?((r||i)&&o.push(r?[r,i]:i),i=r=void 0):":"===t[u]?(r=i,i=void 0):void 0===i&&(i=t[u]);this.filters.push(new Tt(s,o,this.strictFilters))},r.prototype.value=function(i){return d(this,void 0,void 0,function(){var e,n,r;return g(this,function(t){switch(t.label){case 0:return[4,pt(this.initial,i)];case 1:e=t.sent(),n=0,r=this.filters,t.label=2;case 2:return n<r.length?[4,r[n].render(e,i)]:[3,5];case 3:e=t.sent(),t.label=4;case 4:return n++,[3,2];case 5:return[2,e]}})})},r.tokenize=function(t){for(var e=[],n=0;n<t.length;){var r=t[n];if('"'===r||"'"===r){var i=n;for(n+=2;n<t.length&&t[n-1]!==r;++n);e.push(t.slice(i,n))}else if(/\s/.test(r))n++;else if(/[|,:]/.test(r))e.push(t[n++]);else{for(i=n++;n<t.length&&!/[|,:\s]/.test(t[n]);++n);e.push(t.slice(i,n))}}return e},r}(),xt=function(r){function t(t,e){var n=r.call(this,t)||this;return n.value=new Et(t.value,e),n}return i(t,r),t.prototype.render=function(e){return d(this,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return[4,this.value.value(e)];case 1:return[2,a(t.sent())]}})})},t}(yt),qt=function(n){function t(t){var e=n.call(this,t)||this;return e.str=t.value,e}return i(t,n),t.prototype.render=function(){return d(this,void 0,void 0,function(){return g(this,function(t){return[2,this.str]})})},t}(yt),St=function(){function t(t){this.liquid=t}return t.prototype.parse=function(t){for(var e,n=[];e=t.shift();)n.push(this.parseToken(e,t));return n},t.prototype.parseToken=function(e,t){try{return Z.is(e)?new bt(e,t,this.liquid):st.is(e)?new xt(e,this.liquid.options.strictFilters):new qt(e)}catch(t){throw new n(t,e)}},t.prototype.parseStream=function(t){var n=this;return new kt(t,function(t,e){return n.parseToken(t,e)})},t}(),Ot=new RegExp("("+N.source+")\\s*=([^]*)"),Rt={parse:function(t){var e=t.args.match(Ot);x(e,"illegal token "+t.raw),this.key=e[1],this.value=e[2]},render:function(r){return d(this,void 0,void 0,function(){var e,n;return g(this,function(t){switch(t.label){case 0:return e=r.scopes[0],n=this.key,[4,this.liquid.evalValue(this.value,r)];case 1:return e[n]=t.sent(),[2]}})})}},Mt=function(n){function t(t){var e=n.call(this)||this;return e.i=0,e.length=t,e}return i(t,n),t.prototype.next=function(){this.i++},t.prototype.index0=function(){return this.i},t.prototype.index=function(){return this.i+1},t.prototype.first=function(){return 0===this.i},t.prototype.last=function(){return this.i===this.length-1},t.prototype.rindex=function(){return this.length-this.i},t.prototype.rindex0=function(){return this.length-this.i-1},t.prototype.valueOf=function(){return JSON.stringify(this)},t}(f),Lt=new RegExp("^("+N.source+")\\s+in\\s+("+V.source+")(?:\\s+"+G.source+")*(?:\\s+(reversed))?(?:\\s+"+G.source+")*$"),Pt={type:"block",parse:function(t,e){var n,r=this,i=Lt.exec(t.args);x(i,"illegal tag: "+t.raw),this.variable=i[1],this.collection=i[2],this.reversed=!!i[3],this.templates=[],this.elseTemplates=[];var s=this.liquid.parser.parseStream(e).on("start",function(){return n=r.templates}).on("tag:else",function(){return n=r.elseTemplates}).on("tag:endfor",function(){return s.stop()}).on("template",function(t){return n.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});s.start()},render:function(f,h){return d(this,void 0,void 0,function(){var e,n,r,i,s,o,u,a,c,l;return g(this,function(t){switch(t.label){case 0:return[4,pt(this.collection,f)];case 1:if(v(e=t.sent())||(p(e)&&0<e.length?e=[e]:w(e)&&(e=Object.keys(e).map(function(t){return[t,e[t]]}))),!v(e)||!e.length)return[2,this.liquid.renderer.renderTemplates(this.elseTemplates,f)];n=h.offset||0,r=void 0===h.limit?e.length:h.limit,e=e.slice(n,n+r),this.reversed&&e.reverse(),i={forloop:new Mt(e.length)},f.push(i),s="",o=0,u=e,t.label=2;case 2:if(!(o<u.length))return[3,8];a=u[o],i[this.variable]=a,t.label=3;case 3:return t.trys.push([3,5,,6]),c=s,[4,this.liquid.renderer.renderTemplates(this.templates,f)];case 4:return s=c+t.sent(),[3,6];case 5:if("RenderBreakError"!==(l=t.sent()).name)throw l;return s+=l.resolvedHTML,"break"===l.message?[3,8]:[3,6];case 6:i.forloop.next(),t.label=7;case 7:return o++,[3,2];case 8:return f.pop(),[2,s]}})})}},Dt=new RegExp("("+N.source+")"),Ft={parse:function(t,e){var n=this,r=t.args.match(Dt);x(r,t.args+" not valid identifier"),this.variable=r[1],this.templates=[];var i=this.liquid.parser.parseStream(e);i.on("tag:endcapture",function(){return i.stop()}).on("template",function(t){return n.templates.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")}),i.start()},render:function(n){return d(this,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return[4,this.liquid.renderer.renderTemplates(this.templates,n)];case 1:return e=t.sent(),n.scopes[0][this.variable]=e,[2]}})})}},Ut={parse:function(t,e){var n=this;this.cond=t.args,this.cases=[],this.elseTemplates=[];var r=[],i=this.liquid.parser.parseStream(e).on("tag:when",function(t){n.cases.push({val:t.args,templates:r=[]})}).on("tag:else",function(){return r=n.elseTemplates}).on("tag:endcase",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(s){return d(this,void 0,void 0,function(){var e,n,r,i;return g(this,function(t){switch(t.label){case 0:e=0,t.label=1;case 1:return e<this.cases.length?[4,pt((n=this.cases[e]).val,s)]:[3,5];case 2:return r=t.sent(),[4,pt(this.cond,s)];case 3:if(i=t.sent(),r===i)return[2,this.liquid.renderer.renderTemplates(n.templates,s)];t.label=4;case 4:return e++,[3,1];case 5:return[2,this.liquid.renderer.renderTemplates(this.elseTemplates,s)]}})})}},jt={parse:function(t,e){var n=this.liquid.parser.parseStream(e);n.on("token",function(t){"endcomment"===t.name&&n.stop()}).on("end",function(){throw new Error("tag "+t.raw+" not closed")}),n.start()}},_t=/[^\s,]+/,At=new RegExp("with\\s+("+V.source+")"),Ht={parse:function(t){var e=_t.exec(t.args);e&&(this.staticValue=e[0]),(e=V.exec(t.args))&&(this.value=e[0]),(e=At.exec(t.args))&&(this.with=e[1])},render:function(c,l){return d(this,void 0,void 0,function(){var e,n,r,i,s,o,u,a;return g(this,function(t){switch(t.label){case 0:return c.opts.dynamicPartials?X.exec(this.value)?(n=this.value.slice(1,-1),[4,this.liquid.parseAndRender(n,c.getAll(),c.opts)]):[3,2]:[3,5];case 1:return e=t.sent(),[3,4];case 2:return[4,gt(this.value,c)];case 3:e=t.sent(),t.label=4;case 4:return[3,6];case 5:e=this.staticValue,t.label=6;case 6:return x(e,"cannot include with empty filename"),r=c.blocks,i=c.blockMode,c.blocks={},c.blockMode=L.OUTPUT,this.with?(s=l,o=e,[4,gt(this.with,c)]):[3,8];case 7:s[o]=t.sent(),t.label=8;case 8:return[4,this.liquid.getTemplate(e,c.opts)];case 9:return u=t.sent(),c.push(l),[4,this.liquid.renderer.renderTemplates(u,c)];case 10:return a=t.sent(),c.pop(l),c.blocks=r,c.blockMode=i,[2,a]}})})}},Nt={parse:function(t){var e=t.args.match(N);x(e,"illegal identifier "+t.args),this.variable=e[0]},render:function(t){var e=t.environments;return"number"!=typeof e[this.variable]&&(e[this.variable]=0),--e[this.variable]}},zt=new RegExp("^(?:("+V.source+")\\s*:\\s*)?(.*)$"),Yt=new RegExp(V.source,"g"),$t={parse:function(t){var e=zt.exec(t.args);x(e,"illegal tag: "+t.raw),this.group=e[1]||"";var n=e[2];for(this.candidates=[];e=Yt.exec(n);)this.candidates.push(e[0]);x(this.candidates.length,"empty candidates: "+t.raw)},render:function(o){return d(this,void 0,void 0,function(){var e,n,r,i,s;return g(this,function(t){switch(t.label){case 0:return[4,gt(this.group,o)];case 1:return e=t.sent(),n="cycle:"+e+":"+this.candidates.join(","),r=o.groups,void 0===(i=r[n])&&(i=r[n]=0),s=this.candidates[i],i=(i+1)%this.candidates.length,r[n]=i,[2,gt(s,o)]}})})}},It={parse:function(t,e){var n,r=this;this.branches=[],this.elseTemplates=[];var i=this.liquid.parser.parseStream(e).on("start",function(){return r.branches.push({cond:t.args,templates:n=[]})}).on("tag:elsif",function(t){r.branches.push({cond:t.args,templates:n=[]})}).on("tag:else",function(){return n=r.elseTemplates}).on("tag:endif",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(i){return d(this,void 0,void 0,function(){var e,n,r;return g(this,function(t){switch(t.label){case 0:e=0,n=this.branches,t.label=1;case 1:return e<n.length?[4,pt((r=n[e]).cond,i)]:[3,4];case 2:if(vt(t.sent()))return[2,this.liquid.renderer.renderTemplates(r.templates,i)];t.label=3;case 3:return e++,[3,1];case 4:return[2,this.liquid.renderer.renderTemplates(this.elseTemplates,i)]}})})}},Ct={parse:function(t){var e=t.args.match(N);x(e,"illegal identifier "+t.args),this.variable=e[0]},render:function(t){var e=t.environments;"number"!=typeof e[this.variable]&&(e[this.variable]=0);var n=e[this.variable];return e[this.variable]++,n}},Bt=/\S+/,Vt={parse:function(t,e){var n=Bt.exec(t.args);n&&(this.staticLayout=n[0]),(n=V.exec(t.args))&&(this.layout=n[0]),this.tpls=this.liquid.parser.parse(e)},render:function(o,u){return d(this,void 0,void 0,function(){var e,n,r,i,s;return g(this,function(t){switch(t.label){case 0:return o.opts.dynamicPartials?[4,gt(this.layout,o)]:[3,2];case 1:return n=t.sent(),[3,3];case 2:n=this.staticLayout,t.label=3;case 3:return x(e=n,"cannot apply layout with empty filename"),o.blockMode=L.STORE,[4,this.liquid.renderer.renderTemplates(this.tpls,o)];case 4:return r=t.sent(),void 0===o.blocks[""]&&(o.blocks[""]=r),[4,this.liquid.getTemplate(e,o.opts)];case 5:return i=t.sent(),o.push(u),o.blockMode=L.OUTPUT,[4,this.liquid.renderer.renderTemplates(i,o)];case 6:return s=t.sent(),o.pop(u),[2,s]}})})}},Gt={parse:function(t,e){var n=this,r=/\w+/.exec(t.args);this.block=r?r[0]:"",this.tpls=[];var i=this.liquid.parser.parseStream(e).on("tag:endblock",function(){return i.stop()}).on("template",function(t){return n.tpls.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});i.start()},render:function(i){return d(this,void 0,void 0,function(){var e,n,r;return g(this,function(t){switch(t.label){case 0:return void 0===(e=i.blocks[this.block])?[3,1]:(r=e,[3,3]);case 1:return[4,this.liquid.renderer.renderTemplates(this.tpls,i)];case 2:r=t.sent(),t.label=3;case 3:return n=r,i.blockMode===L.STORE?(i.blocks[this.block]=n,[2,""]):[2,n]}})})}},Wt={parse:function(t,e){var n=this;this.tokens=[];var r=this.liquid.parser.parseStream(e);r.on("token",function(t){"endraw"===t.name?r.stop():n.tokens.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")}),r.start()},render:function(){return this.tokens.map(function(t){return t.raw}).join("")}},Jt=function(r){function t(t,e){var n=r.call(this,t)||this;return n.length=t,n.cols=e,n}return i(t,r),t.prototype.row=function(){return Math.floor(this.i/this.cols)+1},t.prototype.col0=function(){return this.i%this.cols},t.prototype.col=function(){return this.col0()+1},t.prototype.col_first=function(){return 0===this.col0()},t.prototype.col_last=function(){return this.col()===this.cols},t}(Mt),Xt=new RegExp("^("+N.source+")\\s+in\\s+("+V.source+")(?:\\s+"+G.source+")*$"),Kt={assign:Rt,for:Pt,capture:Ft,case:Ut,comment:jt,include:Ht,decrement:Nt,increment:Ct,cycle:$t,if:It,layout:Vt,block:Gt,raw:Wt,tablerow:{parse:function(t,e){var n,r=this,i=Xt.exec(t.args);x(i,"illegal tag: "+t.raw),this.variable=i[1],this.collection=i[2],this.templates=[];var s=this.liquid.parser.parseStream(e).on("start",function(){return n=r.templates}).on("tag:endtablerow",function(){return s.stop()}).on("template",function(t){return n.push(t)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});s.start()},render:function(l,f){return d(this,void 0,void 0,function(){var e,n,r,i,s,o,u,a,c;return g(this,function(t){switch(t.label){case 0:return[4,pt(this.collection,l)];case 1:e=t.sent()||[],n=f.offset||0,r=void 0===f.limit?e.length:f.limit,e=e.slice(n,n+r),i=f.cols||e.length,s=new Jt(e.length,i),o={tablerowloop:s},l.push(o),u="",a=0,t.label=2;case 2:return a<e.length?(o[this.variable]=e[a],0===s.col0()&&(1!==s.row()&&(u+="</tr>"),u+='<tr class="row'+s.row()+'">'),u+='<td class="col'+s.col()+'">',c=u,[4,this.liquid.renderer.renderTemplates(this.templates,l)]):[3,5];case 3:u=c+t.sent(),u+="</td>",t.label=4;case 4:return a++,s.next(),[3,2];case 5:return e.length&&(u+="</tr>"),l.pop(o),[2,u]}})})}},unless:{parse:function(t,e){var n,r=this;this.templates=[],this.elseTemplates=[];var i=this.liquid.parser.parseStream(e).on("start",function(){n=r.templates,r.cond=t.args}).on("tag:else",function(){return n=r.elseTemplates}).on("tag:endunless",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(e){return d(this,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return[4,pt(this.cond,e)];case 1:return[2,mt(t.sent())?this.liquid.renderer.renderTemplates(this.templates,e):this.liquid.renderer.renderTemplates(this.elseTemplates,e)]}})})}},break:{render:function(){return d(this,void 0,void 0,function(){return g(this,function(t){throw new k("break")})})}},continue:{render:function(){return d(this,void 0,void 0,function(){return g(this,function(t){throw new k("continue")})})}}},Qt={"&":"&","<":"<",">":">",'"':""","'":"'"},Zt={"&":"&","<":"<",">":">",""":'"',"'":"'"};function te(t){return String(t).replace(/&|<|>|"|'/g,function(t){return Qt[t]})}var ee={escape:te,escape_once:function(t){return te(String(t).replace(/&(amp|lt|gt|#34|#39);/g,function(t){return Zt[t]}))},newline_to_br:function(t){return t.replace(/\n/g,"<br />")},strip_html:function(t){return t.replace(/<script.*?<\/script>|<!--.*?-->|<style.*?<\/style>|<.*?>/g,"")}},ne={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)},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,n){return String(t).split(e).join(n)},replace_first:function(t,e,n){return String(t).replace(e,n)},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,n){return void 0===e&&(e=50),void 0===n&&(n="..."),(t=String(t)).length<=e?t:t.substr(0,e-n.length)+n},truncatewords:function(t,e,n){void 0===e&&(e=15),void 0===n&&(n="...");var r=t.split(/\s+/),i=r.slice(0,e).join(" ");return r.length>=e&&(i+=n),i}},re={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:function(t,e){return t-e},modulo:function(t,e){return t%e},round:function(t,e){void 0===e&&(e=0);var n=Math.pow(10,e);return Math.round(t*n)/n},plus:function(t,e){return Number(t)+Number(e)},times:function(t,e){return t*e}},ie={url_decode:function(t){return t.split("+").map(decodeURIComponent).join(" ")},url_encode:function(t){return t.split(" ").map(encodeURIComponent).join("+")}},se={join:function(t,e){return t.join(void 0===e?" ":e)},last:function(t){return h(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},concat:function(t,e){return Array.prototype.concat.call(t,e)},slice:function(t,e,n){return void 0===n&&(n=1),t.slice(e,e+n)},uniq:function(t){var e={};return(t||[]).filter(function(t){return!e.hasOwnProperty(String(t))&&(e[String(t)]=!0)})}},oe=["January","February","March","April","May","June","July","August","September","October","November","December"],ue=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ae=oe.map(fe),ce=ue.map(fe),le={1:"st",2:"nd",3:"rd",default:"th"};function fe(t){return t.slice(0,3)}var he={daysInMonth:function(t){return[31,he.isLeapYear(t)?29:28,31,30,31,30,31,31,30,31,30,31]},getDayOfYear:function(t){for(var e=0,n=0;n<t.getMonth();++n)e+=he.daysInMonth(t)[n];return e+t.getDate()},getWeekOfYear:function(t,e){var n=this.getDayOfYear(t)+(e-t.getDay()),r=7-new Date(t.getFullYear(),0,1).getDay()+e;return l(String(Math.floor((n-r)/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(),n=parseInt(e.slice(-1));return le[n]||le.default},century:function(t){return parseInt(t.getFullYear().toString().substring(0,2),10)}},pe={a:function(t){return ce[t.getDay()]},A:function(t){return ue[t.getDay()]},b:function(t){return ae[t.getMonth()]},B:function(t){return oe[t.getMonth()]},c:function(t){return t.toLocaleString()},C:function(t){return he.century(t)},d:function(t){return l(t.getDate(),2,"0")},e:function(t){return l(t.getDate(),2)},H:function(t){return l(t.getHours(),2,"0")},I:function(t){return l(String(t.getHours()%12||12),2,"0")},j:function(t){return l(he.getDayOfYear(t),3,"0")},k:function(t){return l(t.getHours(),2)},l:function(t){return l(String(t.getHours()%12||12),2)},L:function(t){return l(t.getMilliseconds(),3,"0")},m:function(t){return l(t.getMonth()+1,2,"0")},M:function(t){return l(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 he.getSuffix(t)},s:function(t){return Math.round(t.valueOf()/1e3)},S:function(t){return l(t.getSeconds(),2,"0")},u:function(t){return t.getDay()||7},U:function(t){return he.getWeekOfYear(t,0)},w:function(t){return t.getDay()},W:function(t){return he.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?"-":"+")+l(String(Math.abs(e)),4,"0")},"%":function(){return"%"}};pe.h=pe.b,pe.N=pe.L;var de=m({},ee,ne,re,ie,{date:function(t,e){var n,r=t;return"now"===t?r=new Date:p(t)&&(r=new Date(t)),(n=r)instanceof Date&&!isNaN(n.getTime())?function(t,e){for(var n="",r=e;;){var i=/%./g,s=i.exec(r);if(!s)return n+r;n+=r.slice(0,i.lastIndex-2),r=r.slice(i.lastIndex);var o=s[0].charAt(1),u=pe[o];n+=u?u(t):"%"+o}}(r,e):t}},{default:function(t,e){return vt(t)?t:e}},se);return function(){function e(t){void 0===t&&(t={});var n=this;this.cache={},this.options=M(R(t)),this.parser=new St(this),this.renderer=new ut,this.tokenizer=new ot(this.options),o(Kt,function(t,e){return n.registerTag(e,t)}),o(de,function(t,e){return n.registerFilter(e,t)})}return e.prototype.parse=function(t,e){var n=this.tokenizer.tokenize(t,e);return this.parser.parse(n)},e.prototype.render=function(t,e,n){var r=m({},this.options,R(n)),i=new P(e,r);return this.renderer.renderTemplates(t,i)},e.prototype.parseAndRender=function(n,r,i){return d(this,void 0,void 0,function(){var e;return g(this,function(t){switch(t.label){case 0:return[4,this.parse(n)];case 1:return e=t.sent(),[2,this.render(e,r,i)]}})})},e.prototype.getTemplate=function(f,h){return d(this,void 0,void 0,function(){var e,n,r,i,s,o,u,a,c,l=this;return g(this,function(t){switch(t.label){case 0:e=R(h),n=e.root?e.root.concat(this.options.root):this.options.root,r=n.map(function(t){return F.resolve(t,f,l.options.extname)}),i=0,s=r,t.label=1;case 1:return i<s.length?(o=s[i],[4,F.exists(o)]):[3,5];case 2:return t.sent()?this.options.cache&&this.cache[o]?[2,this.cache[o]]:(a=this.parse,[4,F.readFile(o)]):[3,4];case 3:return u=a.apply(this,[t.sent(),o]),this.options.cache&&(this.cache[o]=u),[2,u];case 4:return i++,[3,1];case 5:throw(c=new Error("ENOENT")).message='ENOENT: Failed to lookup "'+f+'" in "'+n+'"',c.code="ENOENT",c}})})},e.prototype.renderFile=function(r,i,s){return d(this,void 0,void 0,function(){var e,n;return g(this,function(t){switch(t.label){case 0:return e=R(s),[4,this.getTemplate(r,e)];case 1:return n=t.sent(),[2,this.render(n,i,s)]}})})},e.prototype.evalValue=function(t,e){return new Et(t,this.options.strictFilters).value(e)},e.prototype.registerFilter=function(t,e){return Tt.register(t,e)},e.prototype.registerTag=function(t,e){return bt.register(t,e)},e.prototype.plugin=function(t){return t.call(this,e)},e.prototype.express=function(){var i=this;return function(t,e,n){var r={root:this.root};i.renderFile(t,e,r).then(function(t){return n(null,t)},n)}},(e.default=e).isTruthy=vt,e.isFalsy=mt,e.evalExp=pt,e.evalValue=gt,e.Types=D,e}()}); | ||
//# sourceMappingURL=liquid.min.js.map |
import Token from './token'; | ||
export default class DelimitedToken extends Token { | ||
trimLeft: boolean; | ||
trimRight: boolean; | ||
constructor(raw: string, value: string, input: string, line: number, pos: number, file?: string); | ||
constructor(raw: string, value: string, input: string, line: number, pos: number, trimLeft: boolean, trimRight: boolean, file?: string); | ||
} |
import Token from './token'; | ||
export default class HTMLToken extends Token { | ||
constructor(str: string, input: string, line: number, col: number, file?: string); | ||
static is(token: Token): token is HTMLToken; | ||
} |
import DelimitedToken from './delimited-token'; | ||
import Token from './token'; | ||
import { NormalizedFullOptions } from '../liquid-options'; | ||
export default class OutputToken extends DelimitedToken { | ||
constructor(raw: string, value: string, input: string, line: number, pos: number, file?: string); | ||
constructor(raw: string, value: string, input: string, line: number, pos: number, options: NormalizedFullOptions, file?: string); | ||
static is(token: Token): token is OutputToken; | ||
} |
@@ -11,3 +11,3 @@ import Token from '../parser/token'; | ||
on<T extends ITemplate | Token | undefined>(name: string, cb: (arg: T) => void): ParseStream; | ||
trigger<T extends Token | ITemplate>(event: string, arg?: T): boolean; | ||
private trigger; | ||
start(): this; | ||
@@ -14,0 +14,0 @@ stop(): this; |
import DelimitedToken from './delimited-token'; | ||
import Token from './token'; | ||
import { NormalizedFullOptions } from '../liquid-options'; | ||
export default class TagToken extends DelimitedToken { | ||
name: string; | ||
args: string; | ||
constructor(raw: string, value: string, input: string, line: number, pos: number, file?: string); | ||
constructor(raw: string, value: string, input: string, line: number, pos: number, options: NormalizedFullOptions, file?: string); | ||
static is(token: Token): token is TagToken; | ||
} |
export default class Token { | ||
trimLeft: boolean; | ||
trimRight: boolean; | ||
type: string; | ||
@@ -3,0 +5,0 @@ line: number; |
import Token from './token'; | ||
import { NormalizedFullOptions } from '../liquid-options'; | ||
export default class Tokenizer { | ||
options: NormalizedFullOptions; | ||
private options; | ||
constructor(options?: NormalizedFullOptions); | ||
tokenize(input: string, file?: string): Token[]; | ||
} |
@@ -1,5 +0,5 @@ | ||
import Scope from '../scope/scope'; | ||
import Context from '../context/context'; | ||
import ITemplate from '../template/itemplate'; | ||
export default class Render { | ||
renderTemplates(templates: ITemplate[], scope: Scope): Promise<string>; | ||
renderTemplates(templates: ITemplate[], ctx: Context): Promise<string>; | ||
} |
@@ -1,6 +0,6 @@ | ||
import Scope from '../scope/scope'; | ||
export declare function parseExp(exp: string, scope: Scope): Promise<any>; | ||
export declare function evalExp(str: string, scope: Scope): Promise<any>; | ||
export declare function evalValue(str: string | undefined, scope: Scope): Promise<any>; | ||
import Context from '../context/context'; | ||
export declare function parseExp(exp: string, ctx: Context): Promise<any>; | ||
export declare function evalExp(str: string, ctx: Context): Promise<any>; | ||
export declare function evalValue(str: string | undefined, ctx: Context): Promise<any>; | ||
export declare function isTruthy(val: any): boolean; | ||
export declare function isFalsy(val: any): boolean; |
@@ -1,2 +0,2 @@ | ||
import Scope from '../../scope/scope'; | ||
import Context from '../../context/context'; | ||
import { FilterImpl } from './filter-impl'; | ||
@@ -10,5 +10,5 @@ export declare type FilterArgs = Array<string | [string?, string?]>; | ||
constructor(name: string, args: FilterArgs, strictFilters: boolean); | ||
render(value: any, scope: Scope): Promise<any>; | ||
render(value: any, ctx: Context): Promise<any>; | ||
static register(name: string, filter: FilterImpl): void; | ||
static clear(): void; | ||
} |
@@ -1,6 +0,6 @@ | ||
import Scope from '../scope/scope'; | ||
import Context from '../context/context'; | ||
import Token from '../parser/token'; | ||
export default interface ITemplate { | ||
token: Token; | ||
render(scope: Scope): Promise<string>; | ||
render(ctx: Context): Promise<string>; | ||
} |
import Value from './value'; | ||
import Template from '../template/template'; | ||
import ITemplate from '../template/itemplate'; | ||
import Scope from '../scope/scope'; | ||
import Context from '../context/context'; | ||
import OutputToken from '../parser/output-token'; | ||
@@ -9,3 +9,3 @@ export default class Output extends Template<OutputToken> implements ITemplate { | ||
constructor(token: OutputToken, strictFilters: boolean); | ||
render(scope: Scope): Promise<string>; | ||
render(ctx: Context): Promise<string>; | ||
} |
@@ -1,2 +0,2 @@ | ||
import Scope from '../../scope/scope'; | ||
import Context from '../../context/context'; | ||
/** | ||
@@ -10,3 +10,3 @@ * Key-Value Pairs Representing Tag Arguments | ||
[key: string]: any; | ||
static create(markup: string, scope: Scope): Promise<Hash>; | ||
static create(markup: string, ctx: Context): Promise<Hash>; | ||
} |
@@ -1,2 +0,2 @@ | ||
import Scope from '../../scope/scope'; | ||
import Context from '../../context/context'; | ||
import TagToken from '../../parser/tag-token'; | ||
@@ -8,3 +8,3 @@ import Token from '../../parser/token'; | ||
parse?: (this: ITagImpl, token: TagToken, remainingTokens: Array<Token>) => void; | ||
render?: (this: ITagImpl, scope: Scope, hash: Hash) => any | Promise<any>; | ||
render?: (this: ITagImpl, ctx: Context, hash: Hash) => any | Promise<any>; | ||
} |
@@ -1,2 +0,2 @@ | ||
import Scope from '../../scope/scope'; | ||
import Context from '../../context/context'; | ||
import ITagImplOptions from './itag-impl-options'; | ||
@@ -15,5 +15,5 @@ import Liquid from '../../liquid'; | ||
constructor(token: TagToken, tokens: Token[], liquid: Liquid); | ||
render(scope: Scope): Promise<string>; | ||
render(ctx: Context): Promise<string>; | ||
static register(name: string, tag: ITagImplOptions): void; | ||
static clear(): void; | ||
} |
@@ -1,7 +0,6 @@ | ||
import { Filter } from './filter/filter'; | ||
import Scope from '../scope/scope'; | ||
import Context from '../context/context'; | ||
export default class Value { | ||
private strictFilters; | ||
initial: string; | ||
filters: Array<Filter>; | ||
private initial; | ||
private filters; | ||
/** | ||
@@ -13,4 +12,4 @@ * @param str value string, like: "i have a dream | truncate: 3 | ||
private parseFilter; | ||
value(scope: Scope): Promise<any>; | ||
value(ctx: Context): Promise<any>; | ||
static tokenize(str: string): Array<'|' | ',' | ':' | string>; | ||
} |
@@ -1,1 +0,1 @@ | ||
export default function (predicate: any, message?: string): void; | ||
export default function <T>(predicate: T | null | undefined, message?: string): void; |
@@ -7,3 +7,2 @@ export declare function isString(value: any): value is string; | ||
export declare function toLiquid(value: any): any; | ||
export declare function create<T1 extends object, T2 extends T1 = T1>(proto: T1): T2; | ||
export declare function isNil(value: any): boolean; | ||
@@ -10,0 +9,0 @@ export declare function isArray(value: any): value is any[]; |
{ | ||
"name": "liquidjs", | ||
"version": "8.0.1", | ||
"version": "8.0.2", | ||
"description": "Liquid template engine by pure JavaScript: compatible to shopify, easy to extend.", | ||
@@ -5,0 +5,0 @@ "main": "dist/liquid.common.js", |
@@ -15,31 +15,35 @@ # liquidjs | ||
This is a liquid implementation for both Node.js and browsers. Website: <http://harttle.github.io/liquidjs/>, Live Demo: <https://jsfiddle.net/6u40xbzs/> | ||
A [shopify][shopify/liquid] compatible [Liquid][tutorial] template engine in pure JavaScript. | ||
**Features** | ||
Install via npm: | ||
* Fully compatible to [shopify][shopify/liquid], with all [tags][tags] and [filters][filters] implemented | ||
* Support layout(extend) and include syntax | ||
* In pure JavaScript with Promise-based API | ||
```bash | ||
npm install --save liquidjs | ||
``` | ||
**Differences** | ||
Or include the UMD build: | ||
Though being compatible with [Ruby Liquid](https://github.com/shopify/liquid) is one of our priorities, there're still certain differences. You may need some configuration to get it compatible in these senarios: | ||
```html | ||
<script src="//unpkg.com/liquidjs/dist/liquid.min.js"></script> <!--for production--> | ||
<script src="//unpkg.com/liquidjs/dist/liquid.js"></script> <!--for development--> | ||
``` | ||
* Dynamic file locating (enabled by default), that means layout/partial names are treated as variables in liquidjs. See [#51](https://github.com/harttle/liquidjs/issues/51). | ||
* Truthy and Falsy. All values except `undefined`, `null`, `false` are truthy, whereas in Ruby Liquid all except `nil` and `false` are truthy. See [#26](https://github.com/harttle/liquidjs/pull/26). | ||
* Number Rendering. Since JavaScript do not distinguish `float` and `integer`, we cannot either convert between them nor render regarding to their type. See [#59](https://github.com/harttle/liquidjs/issues/59). | ||
* [.to_liquid()](https://github.com/Shopify/liquid/wiki/Introduction-to-Drops) is replaced by `.toLiquid()` | ||
* [.to_s()](https://www.rubydoc.info/gems/liquid/Liquid/Drop) is replaced by JavaScript `.toString()` | ||
You may need a [Promise polyfill][pp] for Node.js < 4 and ES5 browsers like [IE and Android UC][caniuse-promises]. | ||
## TOC | ||
* Usage | ||
* Get Started | ||
* [Render from String](#render-from-string) | ||
* [Render from File](#render-from-file) | ||
* [Use with Express.js](#use-with-expressjs) | ||
* [Use in Browser](#use-in-browser) | ||
* [Include Partials](#include-partials) | ||
* [Layout Templates (Extends)](#layout-templates-extends) | ||
* API Spec | ||
* [Constructor Options](#options) | ||
* Demos | ||
* Node.js: [/demo/node/](demo/node/) | ||
* Browser: <https://jsfiddle.net/6u40xbzs/>, [/demo/browser/](demo/browser/). | ||
* Express.js: [/demo/express/](demo/express/) | ||
* TypeScript: [/demo/typescript/](demo/typescript/) | ||
* React JS: [/demo/reactjs/](demo/reactjs/) | ||
* Advanced | ||
* [Options](#options) | ||
* [Register Filters](#register-filters), [Builtin Filters](https://github.com/harttle/liquidjs/wiki/Builtin-Filters) | ||
@@ -49,2 +53,4 @@ * [Register Tags](#register-tags), [Builtin Tags](https://github.com/harttle/liquidjs/wiki/Builtin-Tags) | ||
* [Whitespace Control](https://github.com/harttle/liquidjs/wiki/Whitespace-Control) | ||
* [Plugin API](#plugin-api) | ||
* [Differences With shopify/liquid](#differences-with-shopify%2fliquid) | ||
* [Contribute Guidelines](#contribute-guidelines) | ||
@@ -54,11 +60,4 @@ | ||
Install as Node.js dependency: | ||
Just render a template string with a context: | ||
```bash | ||
# You'll need a promise-polyfill for Node.js < 4 | ||
npm install --save liquidjs | ||
``` | ||
Parse and Render: | ||
```javascript | ||
@@ -70,8 +69,6 @@ var Liquid = require('liquidjs'); | ||
.parseAndRender('{{name | capitalize}}', {name: 'alice'}) | ||
.then(console.log); | ||
// outputs 'Alice' | ||
.then(console.log); // outputs 'Alice' | ||
``` | ||
Caching templates: | ||
Caching parsed templates: | ||
@@ -82,5 +79,3 @@ ```javascript | ||
.render(tpl, {name: 'alice'}) | ||
.then(console.log); | ||
// outputs 'Alice' | ||
.then(console.log); // outputs 'Alice' | ||
``` | ||
@@ -92,11 +87,7 @@ | ||
var engine = new Liquid({ | ||
root: path.resolve(__dirname, 'views/'), // dirs to lookup layouts/includes | ||
extname: '.liquid' // the extname used for layouts/includes, defaults "" | ||
root: path.resolve(__dirname, 'views/'), // root for layouts/includes lookup | ||
extname: '.liquid' // used for layouts/includes, defaults "" | ||
}); | ||
engine.renderFile("hello.liquid", {name: 'alice'}) | ||
.then(console.log) // outputs "Alice" | ||
// which is equivalent to: | ||
engine | ||
.renderFile("hello", {name: 'alice'}) | ||
.renderFile("hello", {name: 'alice'}) // will read and render `views/hello.liquid` | ||
.then(console.log) // outputs "Alice" | ||
@@ -114,20 +105,5 @@ ``` | ||
[Here](demo/express/)'s an Express demo. When used with Express.js, | ||
Express [`views`][express-views] will be included when looking up | ||
[`views`][express-views] in express.js will be included when looking up | ||
partials(includes and layouts). | ||
## Use in Browser | ||
You can get a dist file for browsers from | ||
* [Releases][releases] page for liquidjs, or | ||
* unpkg.com: <https://unpkg.com/liquidjs/dist/liquid.min.js> | ||
Here's the demo: | ||
* JSFiddle: <https://jsfiddle.net/6u40xbzs/> | ||
* Demo directory: [/demo/browser/](demo/browser/). | ||
Note: For [IE and Android UC][caniuse-promises] browser, you will need a [Promise polyfill][pp]. | ||
## Include Partials | ||
@@ -267,2 +243,12 @@ | ||
## Differences With shopify/liquid | ||
Though being compatible with [Ruby Liquid](https://github.com/shopify/liquid) is one of our priorities, there're still certain differences. You may need some configuration to get it compatible in these senarios: | ||
* Dynamic file locating (enabled by default), that means layout/partial names are treated as variables in liquidjs. See [#51](https://github.com/harttle/liquidjs/issues/51). | ||
* Truthy and Falsy. All values except `undefined`, `null`, `false` are truthy, whereas in Ruby Liquid all except `nil` and `false` are truthy. See [#26](https://github.com/harttle/liquidjs/pull/26). | ||
* Number Rendering. Since JavaScript do not distinguish `float` and `integer`, we cannot either convert between them nor render regarding to their type. See [#59](https://github.com/harttle/liquidjs/issues/59). | ||
* [.to_liquid()](https://github.com/Shopify/liquid/wiki/Introduction-to-Drops) is replaced by `.toLiquid()` | ||
* [.to_s()](https://www.rubydoc.info/gems/liquid/Liquid/Drop) is replaced by JavaScript `.toString()` | ||
## Contribute Guidelines | ||
@@ -280,3 +266,2 @@ | ||
[gh]: https://pages.github.com/ | ||
[releases]: https://github.com/harttle/liquidjs/releases | ||
[any-promise]: https://github.com/kevinbeaty/any-promise | ||
@@ -290,1 +275,2 @@ [test]: https://github.com/harttle/liquidjs/tree/master/test | ||
[pp]: https://github.com/taylorhakes/promise-polyfill | ||
[tutorial]: https://shopify.github.io/liquid/basics/introduction/ |
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
689490
5622
267