Comparing version 5.1.1 to 5.2.0
@@ -1,1 +0,1 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Liquid=e()}}(function(){return function i(o,u,a){function c(t,e){if(!u[t]){if(!o[t]){var r="function"==typeof require&&require;if(!e&&r)return r(t,!0);if(l)return l(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var s=u[t]={exports:{}};o[t][0].call(s.exports,function(e){return c(o[t][1][e]||e)},s,s.exports,i,o,u,a)}return u[t].exports}for(var l="function"==typeof require&&require,e=0;e<a.length;e++)c(a[e]);return c}({1:[function(e,t,r){"use strict";var s=e("./src/util/strftime.js"),i=e("./src/util/underscore.js"),n=e("./src/syntax.js").isTruthy,o={"&":"&","<":"<",">":">",'"':""","'":"'"},u={"&":"&","<":"<",">":">",""":'"',"'":"'"},a={abs:function(e){return Math.abs(e)},append:function(e,t){return e+t},capitalize:function(e){return f(e).charAt(0).toUpperCase()+e.slice(1)},ceil:function(e){return Math.ceil(e)},concat:function(e,t){return Array.prototype.concat.call(e,t)},date:function(e,t){var r,n=e;return"now"===e?n=new Date:i.isString(e)&&(n=new Date(e)),(r=n)instanceof Date&&!isNaN(r.getTime())?s(n,t):e},default:function(e,t){return n(e)?e:t},divided_by:function(e,t){return e/t},downcase:function(e){return e.toLowerCase()},escape:c,escape_once:function(e){return c(f(e).replace(/&(amp|lt|gt|#34|#39);/g,function(e){return u[e]}))},first:function(e){return e[0]},floor:function(e){return Math.floor(e)},join:function(e,t){return e.join(t)},last:function(e){return i.last(e)},lstrip:function(e){return f(e).replace(/^\s+/,"")},map:function(e,t){return e.map(function(e){return e[t]})},minus:p(function(e,t){return e-t}),modulo:p(function(e,t){return e%t}),newline_to_br:function(e){return e.replace(/\n/g,"<br />")},plus:p(function(e,t){return Number(e)+Number(t)}),prepend:function(e,t){return t+e},remove:function(e,t){return e.split(t).join("")},remove_first:function(e,t){return e.replace(t,"")},replace:function(e,t,r){return f(e).split(t).join(r)},replace_first:function(e,t,r){return f(e).replace(t,r)},reverse:function(e){return e.reverse()},round:function(e,t){var r=Math.pow(10,t||0);return Math.round(e*r,t)/r},rstrip:function(e){return f(e).replace(/\s+$/,"")},size:function(e){return e.length},slice:function(e,t,r){return e.substr(t,void 0===r?1:r)},sort:function(e,t){return e.sort(t)},split:function(e,t){return f(e).split(t)},strip:function(e){return f(e).trim()},strip_html:function(e){return f(e).replace(/<script.*?<\/script>|<!--.*?-->|<style.*?<\/style>|<.*?>/g,"")},strip_newlines:function(e){return f(e).replace(/\n/g,"")},times:function(e,t){return e*t},truncate:function(e,t,r){return r=void 0===r?"...":r,t=t||16,(e=f(e)).length<=t?e:e.substr(0,t-r.length)+r},truncatewords:function(e,t,r){void 0===r&&(r="...");var n=e.split(" "),s=n.slice(0,t).join(" ");return n.length>t&&(s+=r),s},uniq:function(e){var t={};return(e||[]).filter(function(e){return!t.hasOwnProperty(e)&&(t[e]=!0)})},upcase:function(e){return f(e).toUpperCase()},url_encode:encodeURIComponent};function c(e){return f(e).replace(/&|<|>|"|'/g,function(e){return o[e]})}function l(e){var t=(e+"").split(".");return 1<t.length?t[1].length:0}function f(e){return e+""}function p(i){return function(e,t){var r,n,s=(r=e,n=t,Math.max(l(r),l(n)));return i(e,t).toFixed(s)}}function h(r){return i.forOwn(a,function(e,t){return r.registerFilter(t,e)})}h.filters=a,t.exports=h},{"./src/syntax.js":12,"./src/util/strftime.js":19,"./src/util/underscore.js":20}],2:[function(e,t,r){"use strict";var s=e("./src/scope"),i=e("./src/util/underscore.js"),o=e("./src/util/assert.js"),n=e("./src/tokenizer.js"),u=e("./src/util/fs.js").statFileAsync,a=e("./src/util/fs.js").readFileAsync,c=e("path"),l=e("./src/util/url.js"),f=e("./src/render.js"),p=e("./src/lexical.js"),h=e("./src/tag.js"),g=e("./src/filter.js"),d=e("./src/parser"),v=e("./src/syntax.js"),m=e("./tags"),y=e("./filters"),j=e("./src/util/promise.js").anySeries,x=e("./src/util/error.js"),w={init:function(e,t,r){return r.cache&&(this.cache={}),this.options=r,this.tag=e,this.filter=t,this.parser=d(e,t),this.renderer=f(),m(this),y(this),this},parse:function(e,t){var r=n.parse(e,t,this.options);return this.parser.parse(r)},render:function(e,t,r){r=i.assign({},this.options,r);var n=s.factory(t,r);return this.renderer.renderTemplates(e,n)},parseAndRender:function(e,t,r){var n=this;return Promise.resolve().then(function(){return n.parse(e)}).then(function(e){return n.render(e,t,r)})},renderFile:function(e,t,r){var n=this;return r=i.assign({},r),this.getTemplate(e,r.root).then(function(e){return n.render(e,t,r)})},evalValue:function(e,t){var r=this.parser.parseValue(e.trim());return this.renderer.evalValue(r,t)},registerFilter:function(e,t){return this.filter.register(e,t)},registerTag:function(e,t){return this.tag.register(e,t)},lookup:function(t,r){r=this.options.root.concat(r||[]);var e=(r=i.uniq(r)).map(function(e){return c.resolve(e,t)});return j(e,function(e){return u(e).then(function(){return e})}).catch(function(e){throw e.message=e.code+": Failed to lookup "+t+" in: "+r,e})},getTemplate:function(e,t){return"undefined"==typeof XMLHttpRequest?this.getTemplateFromFile(e,t):this.getTemplateFromUrl(e,t)},getTemplateFromFile:function(e,t){var r=this;return c.extname(e)||(e+=this.options.extname),this.lookup(e,t).then(function(t){if(r.options.cache){var e=r.cache[t];return e?Promise.resolve(e):a(t).then(function(e){return r.parse(e)}).then(function(e){return r.cache[t]=e})}return a(t).then(function(e){return r.parse(e,t)})})},getTemplateFromUrl:function(s,e){var i,o=this;if(l.valid(s)?i=s:(l.extname(s)||(s+=this.options.extname),i=l.resolve(e||this.options.root,s)),this.options.cache){var t=this.cache[s];if(t)return Promise.resolve(t)}return new Promise(function(t,r){var n=new XMLHttpRequest;n.onload=function(){if(200<=n.status&&n.status<300){var e=o.parse(n.responseText);o.options.cache&&(o.cache[s]=e),t(e)}else r(new Error(n.statusText))},n.onerror=function(){r(new Error("An error occurred whilst sending the response."))},n.open("GET",i),n.send()})},express:function(n){n=n||{};var s=this;return function(e,t,r){o(Array.isArray(this.root)||i.isString(this.root),"illegal views root, are you using express.js?"),n.root=this.root,s.renderFile(e,t,n).then(function(e){return r(null,e)}).catch(function(e){return r(e)})}}};function b(e){var t;(e=i.assign({root:["."],cache:!1,extname:"",dynamicPartials:!0,trim_tag_right:!1,trim_tag_left:!1,trim_value_right:!1,trim_value_left:!1,greedy:!0,strict_filters:!1,strict_variables:!1},e)).root=(t=e.root,Array.isArray(t)?t:i.isString(t)?[t]:[]);var r=Object.create(w);return r.init(h(),g(e),e),r}b.lexical=p,b.isTruthy=v.isTruthy,b.isFalsy=v.isFalsy,b.evalExp=v.evalExp,b.evalValue=v.evalValue,b.Types={ParseError:x.ParseError,TokenizationEroor:x.TokenizationError,RenderBreakError:x.RenderBreakError,AssertionError:x.AssertionError},t.exports=b},{"./filters":1,"./src/filter.js":6,"./src/lexical.js":7,"./src/parser":9,"./src/render.js":10,"./src/scope":11,"./src/syntax.js":12,"./src/tag.js":13,"./src/tokenizer.js":14,"./src/util/assert.js":15,"./src/util/error.js":16,"./src/util/fs.js":17,"./src/util/promise.js":18,"./src/util/underscore.js":20,"./src/util/url.js":21,"./tags":33,path:4}],3:[function(e,t,r){},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n,s,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};s=function(){return function(){var e=arguments.length;if(0===e)throw new Error("resolveUrl requires at least one argument; got none.");var t=document.createElement("base");if(t.href=arguments[0],1===e)return t.href;var r=document.getElementsByTagName("head")[0];r.insertBefore(t,r.firstChild);for(var n,s=document.createElement("a"),i=1;i<e;i++)s.href=arguments[i],n=s.href,t.href=n;return r.removeChild(t),n}},"object"===((n=void 0)===r?"undefined":i(r))?t.exports=s():n.resolveUrl=s()},{}],6:[function(e,t,r){"use strict";var l=e("./lexical.js"),n=e("./syntax.js"),f=e("./util/assert.js"),s=e("./util/underscore.js"),p=new RegExp(""+l.value.source,"g");t.exports=function(a){a=s.assign({},a);var c={},t={render:function(e,t){var r=this.args.map(function(e){return n.evalValue(e,t)});return r.unshift(e),this.filter.apply(null,r)},parse:function(e){var t=l.filterLine.exec(e);f(t,"illegal filter: "+e);var r=t[1],n=t[2]||"",s=c[r];if("function"!=typeof s){if(a.strict_filters)throw new TypeError("undefined filter: "+r);return this.name=r,this.filter=function(e){return e},this.args=[],this}for(var i=[];t=p.exec(n.trim());){var o=t[0],u=new RegExp(o+"\\s*:","g").exec(t.input);u&&u.index===t.index?i.push("'"+o+"'"):i.push(o)}return this.name=r,this.filter=s,this.args=i,this}};return{construct:function(e){return Object.create(t).parse(e)},register:function(e,t){c[e]=t},clear:function(){c={}}}}},{"./lexical.js":7,"./syntax.js":12,"./util/assert.js":15,"./util/underscore.js":20}],7:[function(e,t,r){"use strict";var n=new RegExp(/'[^']*'/.source+"|"+/"[^"]*"/.source),s=new RegExp("(?:"+n.source+"|[^'\"])*"),i=/-?\d+/,o=/-?\d+\.?\d*|\.?\d+/,u=/true|false/,a=/[\w-]+[?]?/,c=new RegExp("\\[(?:"+n.source+"|[\\w-\\.]+)\\]"),l=new RegExp("(?:"+n.source+"|"+u.source+"|"+o.source+")"),f=new RegExp(a.source+"(?:\\."+a.source+"|"+c.source+")*"),p=new RegExp("(?:"+f.source+"|"+o.source+")"),h=new RegExp("\\("+p.source+"\\.\\."+p.source+"\\)"),g=new RegExp("\\(("+p.source+")\\.\\.("+p.source+")\\)"),d=new RegExp("(?:"+f.source+"|"+l.source+"|"+h.source+")"),v=new RegExp("(?:"+a.source+")\\s*:\\s*(?:"+d.source+")"),m=new RegExp("("+a.source+")\\s*:\\s*("+d.source+")","g"),y=new RegExp("^\\s*("+a.source+")\\s*([\\s\\S]*)\\s*$"),j=new RegExp("^"+l.source+"$","i"),x=new RegExp("^"+f.source+"$"),w=new RegExp("^"+o.source+"$"),b=new RegExp("^"+u.source+"$","i"),E=new RegExp("^"+n.source+"$"),T=new RegExp("^"+g.source+"$"),S=new RegExp("^"+i.source+"$"),k=new RegExp("(?:"+a.source+"\\s*:\\s*)?"+d.source),O=new RegExp(k.source+"(\\s*,\\s*"+k.source+")*"),R=new RegExp(a.source+"(?:\\s*:\\s*"+O.source+")?","g"),A=new RegExp("("+a.source+")(?:\\s*:\\s*("+O.source+"))?"),_=new RegExp("^"+A.source+"$");t.exports={quoted:n,number:o,bool:u,literal:l,filter:R,integer:i,hash:v,hashCapture:m,range:h,rangeCapture:g,identifier:a,value:d,quoteBalanced:s,operators:[/\s+or\s+/,/\s+and\s+/,/==|!=|<=|>=|<|>|\s+contains\s+/],quotedLine:E,numberLine:w,boolLine:b,rangeLine:T,literalLine:j,filterLine:_,tagLine:y,isLiteral:function(e){return j.test(e)},isVariable:function(e){return x.test(e)},parseLiteral:function(e){var t=e.match(w);if(t)return Number(e);if(t=e.match(b))return"true"===e.toLowerCase();if(t=e.match(E))return e.slice(1,-1);throw new TypeError("cannot parse '"+e+"' as literal")},isRange:function(e){return T.test(e)},matchValue:function(e){return d.exec(e)},isInteger:function(e){return S.test(e)}}},{}],8:[function(e,t,r){"use strict";t.exports=function(r){return{"==":function(e,t){return e===t},"!=":function(e,t){return e!==t},">":function(e,t){return null!==e&&null!==t&&t<e},"<":function(e,t){return null!==e&&null!==t&&e<t},">=":function(e,t){return null!==e&&null!==t&&t<=e},"<=":function(e,t){return null!==e&&null!==t&&e<=t},contains:function(e,t){return!!e&&("function"==typeof e.indexOf&&-1<e.indexOf(t))},and:function(e,t){return r(e)&&r(t)},or:function(e,t){return r(e)||r(t)}}}},{}],9:[function(e,t,r){"use strict";var u=e("./lexical.js"),a=e("./util/error.js").ParseError,c=e("./util/assert.js");t.exports=function(r,s){var t={init:function(e){return this.tokens=e,this.handlers={},this},on:function(e,t){return this.handlers[e]=t,this},trigger:function(e,t){var r=this.handlers[e];if("function"==typeof r)return r(t),!0},start:function(){var e;for(this.trigger("start");!this.stopRequested&&(e=this.tokens.shift());)if(!(this.trigger("token",e)||"tag"===e.type&&this.trigger("tag:"+e.name,e))){var t=n(e,this.tokens);this.trigger("template",t)}return this.stopRequested||this.trigger("end"),this},stop:function(){return this.stopRequested=!0,this}};function n(t,e){try{var r=null;return(r="tag"===t.type?i(t,e):"value"===t.type?o(t.value):t).token=t,r}catch(e){throw new a(e,t)}}function i(e,t){return"continue"===e.name||"break"===e.name?e:r.construct(e,t)}function o(e){var t=u.matchValue(e);c(t,"illegal value string: "+e);var r=t[0];e=e.substr(t.index+t[0].length);for(var n=[];t=u.filter.exec(e);)n.push([t[0].trim()]);return{type:"value",initial:r,filters:n.map(function(e){return s.construct(e)})}}return{parse:function(e){for(var t,r=[];t=e.shift();)r.push(n(t,e));return r},parseTag:i,parseStream:function(e){return Object.create(t).init(e)},parseValue:o}}},{"./lexical.js":7,"./util/assert.js":15,"./util/error.js":16}],10:[function(e,t,r){"use strict";var n=e("./syntax.js"),i=e("./util/promise.js").mapSeries,o=e("./util/error.js").RenderBreakError,u=e("./util/error.js").RenderError,a=e("./util/assert.js"),s={renderTemplates:function(e,r){var n=this;a(r,"unable to evalTemplates: scope undefined");var s="";return i(e,function(t){return function(e){var t=this;return"tag"===e.type?this.renderTag(e,r).then(function(e){return void 0===e?"":e}):"value"===e.type?Promise.resolve().then(function(){return t.evalValue(e,r)}).then(function(e){return void 0===e?"":"string"==typeof(t=e)?t:JSON.stringify(t);var t}):Promise.resolve(e.value)}.call(n,t).then(function(e){return s+=e}).catch(function(e){if(e instanceof o)throw e.resolvedHTML=s,e;throw new u(e,t)})}).then(function(){return s})},renderTag:function(e,t){return"continue"===e.name?Promise.reject(new o("continue")):"break"===e.name?Promise.reject(new o("break")):e.render(t)},evalValue:function(e,r){return a(r,"unable to evalValue: scope undefined"),e.filters.reduce(function(e,t){return t.render(e,r)},n.evalExp(e.initial,r))}};t.exports=function(){return Object.create(s)}},{"./syntax.js":12,"./util/assert.js":15,"./util/error.js":16,"./util/promise.js":18}],11:[function(e,t,r){"use strict";var i=e("./util/underscore.js"),u=e("./lexical.js"),a=e("./util/assert.js"),n={getAll:function(){return this.contexts.reduce(function(e,t){return Object.assign(e,t)},Object.create(null))},get:function(e){var r=this,t=this.propertyAccessSeq(e),n=this.findContextFor(t[0])||i.last(this.contexts);return t.reduce(function(e,t){return r.readProperty(e,t)},n)},set:function(e,r){var n=this.propertyAccessSeq(e),s=this.findContextFor(n[0])||i.last(this.contexts);n.some(function(e,t){return!i.isObject(s)||(t===n.length-1?(s[e]=r,!0):(void 0===s[e]&&(s[e]={}),void(s=s[e])))})},unshift:function(e){return this.contexts.unshift(e)},push:function(e){return this.contexts.push(e)},pop:function(t){if(!arguments.length)return this.contexts.pop();var e=this.contexts.findIndex(function(e){return e===t});if(-1===e)throw new TypeError("scope not found, cannot pop");return this.contexts.splice(e,1)[0]},findContextFor:function(e,t){t=t||function(){return!0};for(var r=this.contexts.length-1;0<=r;r--){var n=this.contexts[r];if(t(n)&&e in n)return n}return null},readProperty:function(e,t){var r=void 0;if(r="size"===t&&(i.isArray(e)||i.isString(e))?e.length:i.isNil(e)?void 0:e[t],i.isNil(r)&&this.opts.strict_variables)throw new TypeError("undefined variable: "+t);return r},propertyAccessSeq:function(e){e=String(e);for(var t=[],r="",n=void 0,s=0;s<e.length;)switch(e[s]){case"[":o();var i=e[s+1];/['"]/.test(i)?(n=e.indexOf(i,s+2),a(-1!==n,"unbalanced "+i+": "+e),r=e.slice(s+2,n),o(),s=n+2):(n=c(e,s+1),a(-1!==n,"unbalanced []: "+e),r=e.slice(s+1,n),u.isInteger(r)||(r=this.get(r)),o(),s=n+1);break;case".":o(),s++;break;default:r+=e[s],s++}if(o(),!t.length)throw new TypeError('invalid path:"'+e+'"');return t;function o(){r.length&&t.push(r),r=""}}};function c(e,t){for(var r=1,n=t;n<e.length;n++)if("["===e[n]&&r++,"]"===e[n]&&0===--r)return n;return-1}r.factory=function(e,t){var r=Object.create(n);return r.opts=i.assign({dynamicPartials:!0,strict_variables:!1,strict_filters:!1,blocks:{},root:[]},t),r.contexts=[e||{}],r},r.types={AssignScope:Object.create(null),CaptureScope:Object.create(null),IncrementScope:Object.create(null),DecrementScope:Object.create(null)}},{"./lexical.js":7,"./util/assert.js":15,"./util/underscore.js":20}],12:[function(e,t,r){"use strict";var h=e("./operators.js")(n),g=e("./lexical.js"),d=e("../src/util/assert.js");function v(e,t){if(e=e&&e.trim()){if(g.isLiteral(e))return g.parseLiteral(e);if(g.isVariable(e))return t.get(e);throw new TypeError("cannot eval '"+e+"' as value")}}function n(e){return!s(e)}function s(e){return!1===e||null==e}t.exports={evalExp:function e(t,r){d(r,"unable to evalExp: scope undefined");for(var n,s=g.operators,i=0;i<s.length;i++){var o=s[i],u=new RegExp("^("+g.quoteBalanced.source+")("+o.source+")("+g.quoteBalanced.source+")$");if(n=t.match(u)){var a=e(n[1],r);return(0,h[n[2].trim()])(a,e(n[3],r))}}if(n=t.match(g.rangeLine)){for(var c=v(n[1],r),l=v(n[2],r),f=[],p=c;p<=l;p++)f.push(p);return f}return v(t,r)},evalValue:v,isTruthy:n,isFalsy:s}},{"../src/util/assert.js":15,"./lexical.js":7,"./operators.js":8}],13:[function(e,t,r){"use strict";var o=e("./lexical.js"),u=e("./syntax.js"),i=e("./util/assert.js");t.exports=function(){var n={},s={render:function(e){var t=function(e,t){var r={},n=void 0;for(o.hashCapture.lastIndex=0;n=o.hashCapture.exec(e);){var s=n[1],i=n[2];r[s]=u.evalValue(i,t)}return r}(this.token.args,e),r=this.tagImpl;return"function"!=typeof r.render?Promise.resolve(""):Promise.resolve().then(function(){return r.render(e,t)})},parse:function(e,t){this.type="tag",this.token=e,this.name=e.name;var r=n[this.name];i(r,"tag "+this.name+" not found"),this.tagImpl=Object.create(r),this.tagImpl.parse&&this.tagImpl.parse(e,t)}};return{construct:function(e,t){var r=Object.create(s);return r.parse(e,t),r},register:function(e,t){n[e]=t},clear:function(){n={}}}}},{"./lexical.js":7,"./syntax.js":12,"./util/assert.js":15}],14:[function(e,t,r){"use strict";var m=e("./lexical.js"),y=e("./util/error.js").TokenizationError,j=e("./util/underscore.js"),x=e("./whitespace-ctrl.js"),w=e("./util/assert.js");r.parse=function(i,o,e){w(j.isString(i),"illegal input");for(var r,n,s,t,u,a,c,l=/({%-?([\s\S]*?)-?%})|({{-?([\s\S]*?)-?}})/g,f=0,p=(r=i,n=0,s=-1,{get:function(e){var t=r.slice(s+1,e).split("\n");return n+=t.length-1,s=e,n+1}}),h=0,g=[];t=l.exec(i);h=l.lastIndex)t.index>h&&g.push(v(h,t.index)),g.push(t[1]?d(t[1],t[2].trim(),t.index):(u=t[3],a=t[4].trim(),c=t.index,{type:"value",line:p.get(c),trim_left:"{{-"===u.slice(0,3),trim_right:"-}}"===u.slice(-3),raw:u,value:a,input:i,file:o}));return i.length>h&&g.push(v(h,i.length)),x(g,e),g;function d(e,t,r){var n=t.match(m.tagLine),s={type:"tag",indent:f,line:p.get(r),trim_left:"{%-"===e.slice(0,3),trim_right:"-%}"===e.slice(-3),raw:e,value:t,input:i,file:o};if(!n)throw new y("illegal tag syntax",s);return s.name=n[1],s.args=n[2],s}function v(e,t){var r=i.slice(e,t);return f=j.last(r.split("\n")).length,{type:"html",raw:r,value:r}}},r.whiteSpaceCtrl=x},{"./lexical.js":7,"./util/assert.js":15,"./util/error.js":16,"./util/underscore.js":20,"./whitespace-ctrl.js":22}],15:[function(e,t,r){"use strict";var n=e("./error.js").AssertionError;t.exports=function(e,t){if(!e)throw new n(t=t||"expect "+e+" to be true")}},{"./error.js":16}],16:[function(e,t,r){"use strict";var a=e("./underscore.js");function c(){this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function n(e,t){c.call(this),this.input=t.input,this.line=t.line,this.file=t.file;var r,s,i,n,o,u=(r=t.input,s=t.line,i=r.split("\n"),n=Math.max(s-2,1),o=Math.min(s+3,i.length),a.range(n,o+1).map(function(e){return[e===s?">> ":" ",(t=e,r=o,n=t+"",Array((r+"").length-n.length).join(" ")+n),"| ",i[e-1]].join("");var t,r,n}).join("\n"));this.message=function(e,t){e=e||"",t.file&&(e+=", file:"+t.file);t.line&&(e+=", line:"+t.line);return e}(e.message,t),this.stack=u+"\n"+(this.stack||this.message)+(e.stack?"\nFrom "+e.stack:"")}function s(e,t){n.call(this,{message:e},t)}function i(e,t){a.assign(this,e),this.originalError=e,n.call(this,e,t)}function o(e,t){if(e instanceof o)return e;a.assign(this,e),this.originalError=e,n.call(this,e,t.token)}function u(e){c.call(this),this.message=e+""}function l(e){c.call(this),this.message=e+""}(s.prototype=Object.create(Error.prototype)).constructor=s,(i.prototype=Object.create(Error.prototype)).constructor=i,(o.prototype=Object.create(Error.prototype)).constructor=o,(u.prototype=Object.create(Error.prototype)).constructor=u,(l.prototype=Object.create(Error.prototype)).constructor=l,t.exports={TokenizationError:s,ParseError:i,RenderBreakError:u,AssertionError:l,RenderError:o}},{"./underscore.js":20}],17:[function(e,t,r){"use strict";var s=e("fs");t.exports={readFileAsync:function(e){return new Promise(function(r,n){s.readFile(e,"utf8",function(e,t){e?n(e):r(t)})})},statFileAsync:function(e){return new Promise(function(r,n){s.stat(e,function(e,t){return e?n(e):r(t)})})}}},{fs:3}],18:[function(e,t,r){"use strict";r.anySeries=function(n,s){var e=Promise.reject(new Error("init"));return n.forEach(function(t,r){e=e.catch(function(e){return s(t,r,n)})}),e},r.mapSeries=function(r,n){var s=Promise.resolve("init"),i=[];return r.forEach(function(e,t){s=s.then(function(){return n(e,t,r)}).then(function(e){return i.push(e)})}),s.then(function(){return i})}},{}],19:[function(e,t,r){"use strict";var n=["January","February","March","April","May","June","July","August","September","October","November","December"],s=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],i=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],u={1:"st",2:"nd",3:"rd",default:"th"},a={daysInMonth:function(e){return[31,a.isLeapYear(e)?29:28,31,30,31,30,31,31,30,31,30,31]},getDayOfYear:function(e){for(var t=0,r=0;r<e.getMonth();++r)t+=a.daysInMonth(e)[r];return t+e.getDate()},getWeekOfYear:function(e,t){var r=this.getDayOfYear(e)+(t-e.getDay()),n=7-new Date(e.getFullYear(),0,1).getDay()+t;return c.pad(Math.floor((r-n)/7)+1,2)},isLeapYear:function(e){var t=e.getFullYear();return!(0!=(3&t)||!(t%100||t%400==0&&t))},getSuffix:function(e){var t=e.getDate().toString(),r=parseInt(t.slice(-1));return u[r]||u.default},century:function(e){return parseInt(e.getFullYear().toString().substring(0,2),10)}},c={pad:function(e,t,r){r||(r="0");for(var n=e.toString(),s=t-n.length;0<s--;)n=r+n;return n}},l={a:function(e){return o[e.getDay()]},A:function(e){return i[e.getDay()]},b:function(e){return s[e.getMonth()]},B:function(e){return n[e.getMonth()]},c:function(e){return e.toLocaleString()},C:function(e){return a.century(e)},d:function(e){return c.pad(e.getDate(),2)},e:function(e){return c.pad(e.getDate(),2," ")},H:function(e){return c.pad(e.getHours(),2)},I:function(e){return c.pad(e.getHours()%12||12,2)},j:function(e){return c.pad(a.getDayOfYear(e),3)},k:function(e){return c.pad(e.getHours(),2," ")},l:function(e){return c.pad(e.getHours()%12||12,2," ")},L:function(e){return c.pad(e.getMilliseconds(),3)},m:function(e){return c.pad(e.getMonth()+1,2)},M:function(e){return c.pad(e.getMinutes(),2)},p:function(e){return e.getHours()<12?"AM":"PM"},P:function(e){return e.getHours()<12?"am":"pm"},q:function(e){return a.getSuffix(e)},s:function(e){return Math.round(e.valueOf()/1e3)},S:function(e){return c.pad(e.getSeconds(),2)},u:function(e){return e.getDay()||7},U:function(e){return a.getWeekOfYear(e,0)},w:function(e){return e.getDay()},W:function(e){return a.getWeekOfYear(e,1)},x:function(e){return e.toLocaleDateString()},X:function(e){return e.toLocaleTimeString()},y:function(e){return e.getFullYear().toString().substring(2,4)},Y:function(e){return e.getFullYear()},z:function(e){var t=e.getTimezoneOffset()/60*100;return(0<t?"-":"+")+c.pad(Math.abs(t),4)},"%":function(){return"%"}};l.h=l.b,l.N=l.L;t.exports=function(e,t){for(var r="",n=t;;){var s=/%./g,i=s.exec(n);if(!i)return r+n;r+=n.slice(0,s.lastIndex-2),n=n.slice(s.lastIndex);var o=i[0].charAt(1),u=l[o];r+=u?u.call(this,e):"%"+o}}},{}],20:[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=Object.prototype.toString;function i(e){var t=void 0===e?"undefined":n(e);return null!=e&&("object"===t||"function"===t)}r.isString=function(e){return e instanceof String||"string"==typeof e},r.isObject=i,r.isArray=function(e){return"[object Array]"===s.call(e)},r.isNil=function(e){return null==e},r.isError=function(e){return"Error"===Object.prototype.toString.call(e).substr(-6,5)||"string"==typeof e.message&&"string"==typeof e.name},r.range=function(e,t,r){1===arguments.length&&(t=e,e=0),r=r||1;for(var n=[],s=e;s<t;s+=r)n.push(s);return n},r.last=function(e){return e[e.length-1]},r.forOwn=function(e,t){for(var r in e=e||{})if(e.hasOwnProperty(r)&&!1===t(e[r],r,e))break;return e},r.assign=function(t){return t=i(t)?t:{},Array.prototype.slice.call(arguments,1).forEach(function(e){return Object.assign(t,e)}),t},r.uniq=function(e){for(var t={},r=[],n=0,s=e.length;n<s;++n)t.hasOwnProperty(e[n])||(r.push(e[n]),t[e[n]]=1);return r}},{}],21:[function(e,t,r){"use strict";var n=e("resolve-url"),s=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^/]+?|)(\.[^./]*|))(?:[/]*)$/,i=/^(?:\w+:)?\/\/([^\s.]+\.\S{2}|localhost[:?\d]*)\S*$/,o=e("./underscore");r.extname=function(e){return s.exec(e).slice(1)[3]},r.valid=function(e){return i.test(e)},r.resolve=function(e,t){return"[object Array]"===Object.prototype.toString.call(e)&&(e=e[0]),e&&"/"!==o.last(e)&&(e+="/"),n(e,t)}},{"./underscore":20,"resolve-url":5}],22:[function(e,t,r){"use strict";var n=e("./util/underscore.js");t.exports=function(o,u){u=n.assign({greedy:!0},u);var a=!1;o.forEach(function(e,t){var r,n,s,i;s=e,i=u,!a&&("tag"===s.type?s.trim_left||i.trim_tag_left:"value"===s.type?s.trim_left||i.trim_value_left:void 0)&&function(e,t){if(e&&"html"===e.type){var r=t?/\s+$/g:/[\t\r ]*$/g;e.value=e.value.replace(r,"")}}(o[t-1],u.greedy),"tag"===e.type&&"raw"===e.name&&(a=!0),"tag"===e.type&&"endraw"===e.name&&(a=!1),r=e,n=u,!a&&("tag"===r.type?r.trim_right||n.trim_tag_right:"value"===r.type?r.trim_right||n.trim_value_right:void 0)&&function(e,t){if(e&&"html"===e.type){var r=t?/^\s+/g:/^[\t\r ]*\n?/g;e.value=e.value.replace(r,"")}}(o[t+1],u.greedy)})}},{"./util/underscore.js":20}],23:[function(e,t,r){"use strict";var n=e("..").lexical,s=new RegExp("("+n.identifier.source+")\\s*=(.*)"),i=e("../src/util/assert.js"),o=e("../src/scope").types;t.exports=function(r){r.registerTag("assign",{parse:function(e){var t=e.args.match(s);i(t,"illegal token "+e.raw),this.key=t[1],this.value=t[2]},render:function(e){var t=Object.create(o.AssignScope);return t[this.key]=r.evalValue(this.value,e),e.push(t),Promise.resolve("")}})}},{"..":2,"../src/scope":11,"../src/util/assert.js":15}],24:[function(e,t,r){"use strict";var n=e("..").lexical,o=new RegExp("("+n.identifier.source+")"),u=e("../src/util/assert.js"),s=e("../src/scope.js").types;t.exports=function(i){i.registerTag("capture",{parse:function(t,e){var r=this,n=t.args.match(o);u(n,t.args+" not valid identifier"),this.variable=n[1],this.templates=[];var s=i.parser.parseStream(e);s.on("tag:endcapture",function(e){return s.stop()}).on("template",function(e){return r.templates.push(e)}).on("end",function(e){throw new Error("tag "+t.raw+" not closed")}),s.start()},render:function(r,e){var n=this;return i.renderer.renderTemplates(this.templates,r).then(function(e){var t=Object.create(s.CaptureScope);t[n.variable]=e,r.push(t)})}})}},{"..":2,"../src/scope.js":11,"../src/util/assert.js":15}],25:[function(e,t,r){"use strict";var s=e("..");t.exports=function(i){i.registerTag("case",{parse:function(t,e){var r=this;this.cond=t.args,this.cases=[],this.elseTemplates=[];var n=[],s=i.parser.parseStream(e).on("tag:when",function(e){r.cases.push({val:e.args,templates:n=[]})}).on("tag:else",function(){return n=r.elseTemplates}).on("tag:endcase",function(e){return s.stop()}).on("template",function(e){return n.push(e)}).on("end",function(e){throw new Error("tag "+t.raw+" not closed")});s.start()},render:function(e,t){for(var r=0;r<this.cases.length;r++){var n=this.cases[r];if(s.evalExp(n.val,e)===s.evalExp(this.cond,e))return i.renderer.renderTemplates(n.templates,e)}return i.renderer.renderTemplates(this.elseTemplates,e)}})}},{"..":2}],26:[function(e,t,r){"use strict";t.exports=function(n){n.registerTag("comment",{parse:function(t,e){var r=n.parser.parseStream(e);r.on("token",function(e){"endcomment"===e.name&&r.stop()}).on("end",function(e){throw new Error("tag "+t.raw+" not closed")}),r.start()}})}},{}],27:[function(e,t,r){"use strict";var o=e(".."),n=o.lexical,s=new RegExp("^(?:("+n.value.source+")\\s*:\\s*)?(.*)$"),i=new RegExp(n.value.source,"g"),u=e("../src/util/assert.js");t.exports=function(e){e.registerTag("cycle",{parse:function(e,t){var r=s.exec(e.args);u(r,"illegal tag: "+e.raw),this.group=r[1]||"";var n=r[2];for(this.candidates=[];r=i.exec(n);)this.candidates.push(r[0]);u(this.candidates.length,"empty candidates: "+e.raw)},render:function(e,t){var r="cycle:"+o.evalValue(this.group,e)+":"+this.candidates.join(","),n=e.opts.groups=e.opts.groups||{},s=n[r];void 0===s&&(s=n[r]=0);var i=this.candidates[s];return s=(s+1)%this.candidates.length,n[r]=s,Promise.resolve(o.evalValue(i,e))}})}},{"..":2,"../src/util/assert.js":15}],28:[function(e,t,r){"use strict";var n=e("..").lexical,s=e("../src/util/assert.js"),i=e("../src/scope").types;t.exports=function(e){e.registerTag("decrement",{parse:function(e){var t=e.args.match(n.identifier);s(t,"illegal identifier "+e.args),this.variable=t[0]},render:function(e,t){var r=e.findContextFor(this.variable,function(e){return Object.getPrototypeOf(e)!==i.CaptureScope&&Object.getPrototypeOf(e)!==i.AssignScope});return r||(r=Object.create(i.DecrementScope),e.unshift(r)),"number"!=typeof r[this.variable]&&(r[this.variable]=0),--r[this.variable]}})}},{"..":2,"../src/scope":11,"../src/util/assert.js":15}],29:[function(e,t,r){"use strict";var c=e(".."),n=c.lexical,l=e("../src/util/promise.js").mapSeries,f=e("../src/util/underscore.js"),p=c.Types.RenderBreakError,o=e("../src/util/assert.js"),u=new RegExp("^("+n.identifier.source+")\\s+in\\s+("+n.value.source+")(?:\\s+"+n.hash.source+")*(?:\\s+(reversed))?(?:\\s+"+n.hash.source+")*$");t.exports=function(a){a.registerTag("for",{parse:function(e,t){var r,n=this,s=u.exec(e.args);o(s,"illegal tag: "+e.raw),this.variable=s[1],this.collection=s[2],this.reversed=!!s[3],this.templates=[],this.elseTemplates=[];var i=a.parser.parseStream(t).on("start",function(){return r=n.templates}).on("tag:else",function(){return r=n.elseTemplates}).on("tag:endfor",function(){return i.stop()}).on("template",function(e){return r.push(e)}).on("end",function(){throw new Error("tag "+e.raw+" not closed")});i.start()},render:function(t,e){var n=this,s=c.evalExp(this.collection,t);if(Array.isArray(s)||(f.isString(s)&&0<s.length?s=[s]:f.isObject(s)&&(s=Object.keys(s).map(function(e){return[e,s[e]]}))),!Array.isArray(s)||!s.length)return a.renderer.renderTemplates(this.elseTemplates,t);var r=e.offset||0,i=void 0===e.limit?s.length:e.limit;s=s.slice(r,r+i),this.reversed&&s.reverse();var o=s.map(function(e,t){var r={};return r[n.variable]=e,r.forloop={first:0===t,index:t+1,index0:t,last:t===s.length-1,length:s.length,rindex:s.length-t,rindex0:s.length-t-1},r}),u="";return l(o,function(e){return Promise.resolve().then(function(){return t.push(e)}).then(function(){return a.renderer.renderTemplates(n.templates,t)}).then(function(e){return u+=e}).catch(function(e){if(!(e instanceof p&&(u+=e.resolvedHTML,"continue"===e.message)))throw e}).then(function(){return t.pop(e)})}).catch(function(e){if(!(e instanceof p&&"break"===e.message))throw e}).then(function(){return u})}})}},{"..":2,"../src/util/assert.js":15,"../src/util/promise.js":18,"../src/util/underscore.js":20}],30:[function(e,t,r){"use strict";var o=e("..");t.exports=function(i){i.registerTag("if",{parse:function(t,e){var r,n=this;this.branches=[],this.elseTemplates=[];var s=i.parser.parseStream(e).on("start",function(){return n.branches.push({cond:t.args,templates:r=[]})}).on("tag:elsif",function(e){n.branches.push({cond:e.args,templates:r=[]})}).on("tag:else",function(){return r=n.elseTemplates}).on("tag:endif",function(e){return s.stop()}).on("template",function(e){return r.push(e)}).on("end",function(e){throw new Error("tag "+t.raw+" not closed")});s.start()},render:function(e,t){for(var r=0;r<this.branches.length;r++){var n=this.branches[r],s=o.evalExp(n.cond,e);if(o.isTruthy(s))return i.renderer.renderTemplates(n.templates,e)}return i.renderer.renderTemplates(this.elseTemplates,e)}})}},{"..":2}],31:[function(e,t,r){"use strict";var a=e(".."),c=a.lexical,n=new RegExp("with\\s+("+c.value.source+")"),s=/[^\s,]+/,l=e("../src/util/assert.js");t.exports=function(u){u.registerTag("include",{parse:function(e){var t=s.exec(e.args);t&&(this.staticValue=t[0]),(t=c.value.exec(e.args))&&(this.value=t[0]),(t=n.exec(e.args))&&(this.with=t[1])},render:function(t,r){var n=this,e=void 0;if(t.opts.dynamicPartials)if(c.quotedLine.exec(this.value)){var s=this.value.slice(1,-1);e=u.parseAndRender(s,t.getAll(),t.opts)}else e=Promise.resolve(a.evalValue(this.value,t));else e=Promise.resolve(this.staticValue);var i=t.opts.blocks,o=t.opts.blockMode;return e.then(function(e){return l(e,"cannot include with empty filename"),t.opts.blocks={},t.opts.blockMode="output",n.with&&(r[e]=a.evalValue(n.with,t)),u.getTemplate(e,t.opts.root)}).then(function(e){return t.push(r),u.renderer.renderTemplates(e,t)}).then(function(e){return t.pop(r),t.opts.blocks=i,t.opts.blockMode=o,e})}})}},{"..":2,"../src/util/assert.js":15}],32:[function(e,t,r){"use strict";var n=e(".."),s=e("../src/util/assert.js"),i=n.lexical,o=e("../src/scope").types;t.exports=function(e){e.registerTag("increment",{parse:function(e){var t=e.args.match(i.identifier);s(t,"illegal identifier "+e.args),this.variable=t[0]},render:function(e,t){var r=e.findContextFor(this.variable,function(e){return Object.getPrototypeOf(e)!==o.CaptureScope&&Object.getPrototypeOf(e)!==o.AssignScope});r||(r=Object.create(o.IncrementScope),e.unshift(r)),"number"!=typeof r[this.variable]&&(r[this.variable]=0);var n=r[this.variable];return r[this.variable]++,n}})}},{"..":2,"../src/scope":11,"../src/util/assert.js":15}],33:[function(t,e,r){"use strict";e.exports=function(e){t("./assign.js")(e),t("./capture.js")(e),t("./case.js")(e),t("./comment.js")(e),t("./cycle.js")(e),t("./decrement.js")(e),t("./for.js")(e),t("./if.js")(e),t("./include.js")(e),t("./increment.js")(e),t("./layout.js")(e),t("./raw.js")(e),t("./tablerow.js")(e),t("./unless.js")(e)}},{"./assign.js":23,"./capture.js":24,"./case.js":25,"./comment.js":26,"./cycle.js":27,"./decrement.js":28,"./for.js":29,"./if.js":30,"./include.js":31,"./increment.js":32,"./layout.js":34,"./raw.js":35,"./tablerow.js":36,"./unless.js":37}],34:[function(e,t,r){"use strict";var s=e(".."),n=s.lexical,o=e("../src/util/assert.js"),u=/\S+/;t.exports=function(i){i.registerTag("layout",{parse:function(e,t){var r=u.exec(e.args);r&&(this.staticLayout=r[0]),(r=n.value.exec(e.args))&&(this.layout=r[0]),this.tpls=i.parser.parse(t)},render:function(t,r){var n=t.opts.dynamicPartials?s.evalValue(this.layout,t):this.staticLayout;return o(n,"cannot apply layout with empty filename"),t.opts.blockMode="store",i.renderer.renderTemplates(this.tpls,t).then(function(e){return void 0===t.opts.blocks[""]&&(t.opts.blocks[""]=e),i.getTemplate(n,t.opts.root)}).then(function(e){return t.push(r),t.opts.blockMode="output",i.renderer.renderTemplates(e,t)}).then(function(e){return t.pop(r),e})}}),i.registerTag("block",{parse:function(e,t){var r=this,n=/\w+/.exec(e.args);this.block=n?n[0]:"",this.tpls=[];var s=i.parser.parseStream(t).on("tag:endblock",function(){return s.stop()}).on("template",function(e){return r.tpls.push(e)}).on("end",function(){throw new Error("tag "+e.raw+" not closed")});s.start()},render:function(t){var r=this;return Promise.resolve(t.opts.blocks[this.block]).then(function(e){return void 0===e?i.renderer.renderTemplates(r.tpls,t):e}).then(function(e){return"store"===t.opts.blockMode?(t.opts.blocks[r.block]=e,""):e})}})}},{"..":2,"../src/util/assert.js":15}],35:[function(e,t,r){"use strict";t.exports=function(s){s.registerTag("raw",{parse:function(e,t){var r=this;this.tokens=[];var n=s.parser.parseStream(t);n.on("token",function(e){"endraw"===e.name?n.stop():r.tokens.push(e)}).on("end",function(){throw new Error("tag "+e.raw+" not closed")}),n.start()},render:function(e,t){return this.tokens.map(function(e){return e.raw}).join("")}})}},{}],36:[function(e,t,r){"use strict";var p=e(".."),h=e("../src/util/promise.js").mapSeries,n=p.lexical,o=e("../src/util/assert.js"),u=new RegExp("^("+n.identifier.source+")\\s+in\\s+("+n.value.source+")(?:\\s+"+n.hash.source+")*$");t.exports=function(f){f.registerTag("tablerow",{parse:function(e,t){var r,n=this,s=u.exec(e.args);o(s,"illegal tag: "+e.raw),this.variable=s[1],this.collection=s[2],this.templates=[];var i=f.parser.parseStream(t).on("start",function(){return r=n.templates}).on("tag:endtablerow",function(e){return i.stop()}).on("template",function(e){return r.push(e)}).on("end",function(){throw new Error("tag "+e.raw+" not closed")});i.start()},render:function(r,e){var n,s,i=this,t=p.evalExp(this.collection,r)||[],o="",u=e.offset||0,a=void 0===e.limit?t.length:e.limit,c=e.cols;t=t.slice(u,u+a),c||(c=t.length);var l=t.map(function(e,t){var r={};return r[i.variable]=e,r});return h(l,function(t,e){return n=Math.floor(e/c)+1,1===(s=e%c+1)&&(1!==n&&(o+="</tr>"),o+='<tr class="row'+n+'">'),o+='<td class="col'+s+'">',r.push(t),f.renderer.renderTemplates(i.templates,r).then(function(e){return r.pop(t),o+=e,o+="</td>"})}).then(function(){return 0<n&&(o+="</tr>"),o})}})}},{"..":2,"../src/util/assert.js":15,"../src/util/promise.js":18}],37:[function(e,t,r){"use strict";var n=e("..");t.exports=function(i){i.registerTag("unless",{parse:function(t,e){var r,n=this;this.templates=[],this.elseTemplates=[];var s=i.parser.parseStream(e).on("start",function(e){r=n.templates,n.cond=t.args}).on("tag:else",function(){return r=n.elseTemplates}).on("tag:endunless",function(e){return s.stop()}).on("template",function(e){return r.push(e)}).on("end",function(e){throw new Error("tag "+t.raw+" not closed")});s.start()},render:function(e,t){var r=n.evalExp(this.cond,e);return n.isFalsy(r)?i.renderer.renderTemplates(this.templates,e):i.renderer.renderTemplates(this.elseTemplates,e)}})}},{"..":2}]},{},[2])(2)}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Liquid=e()}}(function(){return function i(o,u,a){function c(t,e){if(!u[t]){if(!o[t]){var r="function"==typeof require&&require;if(!e&&r)return r(t,!0);if(l)return l(t,!0);var n=new Error("Cannot find module '"+t+"'");throw n.code="MODULE_NOT_FOUND",n}var s=u[t]={exports:{}};o[t][0].call(s.exports,function(e){return c(o[t][1][e]||e)},s,s.exports,i,o,u,a)}return u[t].exports}for(var l="function"==typeof require&&require,e=0;e<a.length;e++)c(a[e]);return c}({1:[function(e,t,r){"use strict";var s=e("./src/util/strftime.js"),i=e("./src/util/underscore.js"),n=e("./src/syntax.js").isTruthy,o={"&":"&","<":"<",">":">",'"':""","'":"'"},u={"&":"&","<":"<",">":">",""":'"',"'":"'"},a={abs:function(e){return Math.abs(e)},append:function(e,t){return e+t},capitalize:function(e){return f(e).charAt(0).toUpperCase()+e.slice(1)},ceil:function(e){return Math.ceil(e)},concat:function(e,t){return Array.prototype.concat.call(e,t)},date:function(e,t){var r,n=e;return"now"===e?n=new Date:i.isString(e)&&(n=new Date(e)),(r=n)instanceof Date&&!isNaN(r.getTime())?s(n,t):e},default:function(e,t){return n(e)?e:t},divided_by:function(e,t){return e/t},downcase:function(e){return e.toLowerCase()},escape:c,escape_once:function(e){return c(f(e).replace(/&(amp|lt|gt|#34|#39);/g,function(e){return u[e]}))},first:function(e){return e[0]},floor:function(e){return Math.floor(e)},join:function(e,t){return e.join(t)},last:function(e){return i.last(e)},lstrip:function(e){return f(e).replace(/^\s+/,"")},map:function(e,t){return e.map(function(e){return e[t]})},minus:p(function(e,t){return e-t}),modulo:p(function(e,t){return e%t}),newline_to_br:function(e){return e.replace(/\n/g,"<br />")},plus:p(function(e,t){return Number(e)+Number(t)}),prepend:function(e,t){return t+e},remove:function(e,t){return e.split(t).join("")},remove_first:function(e,t){return e.replace(t,"")},replace:function(e,t,r){return f(e).split(t).join(r)},replace_first:function(e,t,r){return f(e).replace(t,r)},reverse:function(e){return e.reverse()},round:function(e,t){var r=Math.pow(10,t||0);return Math.round(e*r,t)/r},rstrip:function(e){return f(e).replace(/\s+$/,"")},size:function(e){return e.length},slice:function(e,t,r){return e.substr(t,void 0===r?1:r)},sort:function(e,t){return e.sort(t)},split:function(e,t){return f(e).split(t)},strip:function(e){return f(e).trim()},strip_html:function(e){return f(e).replace(/<script.*?<\/script>|<!--.*?-->|<style.*?<\/style>|<.*?>/g,"")},strip_newlines:function(e){return f(e).replace(/\n/g,"")},times:function(e,t){return e*t},truncate:function(e,t,r){return r=void 0===r?"...":r,t=t||16,(e=f(e)).length<=t?e:e.substr(0,t-r.length)+r},truncatewords:function(e,t,r){void 0===r&&(r="...");var n=e.split(" "),s=n.slice(0,t).join(" ");return n.length>t&&(s+=r),s},uniq:function(e){var t={};return(e||[]).filter(function(e){return!t.hasOwnProperty(e)&&(t[e]=!0)})},upcase:function(e){return f(e).toUpperCase()},url_encode:encodeURIComponent};function c(e){return f(e).replace(/&|<|>|"|'/g,function(e){return o[e]})}function l(e){var t=(e+"").split(".");return 1<t.length?t[1].length:0}function f(e){return e+""}function p(i){return function(e,t){var r,n,s=(r=e,n=t,Math.max(l(r),l(n)));return i(e,t).toFixed(s)}}function h(r){return i.forOwn(a,function(e,t){return r.registerFilter(t,e)})}h.filters=a,t.exports=h},{"./src/syntax.js":12,"./src/util/strftime.js":19,"./src/util/underscore.js":20}],2:[function(e,t,r){"use strict";var s=e("./src/scope"),i=e("./src/util/underscore.js"),o=e("./src/util/assert.js"),n=e("./src/tokenizer.js"),u=e("./src/util/fs.js").statFileAsync,a=e("./src/util/fs.js").readFileAsync,c=e("path"),l=e("./src/util/url.js"),f=e("./src/render.js"),p=e("./src/lexical.js"),h=e("./src/tag.js"),g=e("./src/filter.js"),d=e("./src/parser"),v=e("./src/syntax.js"),m=e("./tags"),y=e("./filters"),j=e("./src/util/promise.js").anySeries,x=e("./src/util/error.js"),w={init:function(e,t,r){return r.cache&&(this.cache={}),this.options=r,this.tag=e,this.filter=t,this.parser=d(e,t),this.renderer=f(),m(this),y(this),this},parse:function(e,t){var r=n.parse(e,t,this.options);return this.parser.parse(r)},render:function(e,t,r){r=i.assign({},this.options,r);var n=s.factory(t,r);return this.renderer.renderTemplates(e,n)},parseAndRender:function(e,t,r){var n=this;return Promise.resolve().then(function(){return n.parse(e)}).then(function(e){return n.render(e,t,r)})},renderFile:function(e,t,r){var n=this;return r=i.assign({},r),this.getTemplate(e,r.root).then(function(e){return n.render(e,t,r)})},evalValue:function(e,t){var r=this.parser.parseValue(e.trim());return this.renderer.evalValue(r,t)},registerFilter:function(e,t){return this.filter.register(e,t)},registerTag:function(e,t){return this.tag.register(e,t)},lookup:function(t,r){r=this.options.root.concat(r||[]);var e=(r=i.uniq(r)).map(function(e){return c.resolve(e,t)});return j(e,function(e){return u(e).then(function(){return e})}).catch(function(e){throw e.message=e.code+": Failed to lookup "+t+" in: "+r,e})},getTemplate:function(e,t){return"undefined"==typeof XMLHttpRequest?this.getTemplateFromFile(e,t):this.getTemplateFromUrl(e,t)},getTemplateFromFile:function(e,t){var r=this;return c.extname(e)||(e+=this.options.extname),this.lookup(e,t).then(function(t){if(r.options.cache){var e=r.cache[t];return e?Promise.resolve(e):a(t).then(function(e){return r.parse(e)}).then(function(e){return r.cache[t]=e})}return a(t).then(function(e){return r.parse(e,t)})})},getTemplateFromUrl:function(s,e){var i,o=this;if(l.valid(s)?i=s:(l.extname(s)||(s+=this.options.extname),i=l.resolve(e||this.options.root,s)),this.options.cache){var t=this.cache[s];if(t)return Promise.resolve(t)}return new Promise(function(t,r){var n=new XMLHttpRequest;n.onload=function(){if(200<=n.status&&n.status<300){var e=o.parse(n.responseText);o.options.cache&&(o.cache[s]=e),t(e)}else r(new Error(n.statusText))},n.onerror=function(){r(new Error("An error occurred whilst sending the response."))},n.open("GET",i),n.send()})},express:function(n){n=n||{};var s=this;return function(e,t,r){o(Array.isArray(this.root)||i.isString(this.root),"illegal views root, are you using express.js?"),n.root=this.root,s.renderFile(e,t,n).then(function(e){return r(null,e)}).catch(function(e){return r(e)})}}};function b(e){var t;(e=i.assign({root:["."],cache:!1,extname:"",dynamicPartials:!0,trim_tag_right:!1,trim_tag_left:!1,trim_value_right:!1,trim_value_left:!1,greedy:!0,strict_filters:!1,strict_variables:!1},e)).root=(t=e.root,Array.isArray(t)?t:i.isString(t)?[t]:[]);var r=Object.create(w);return r.init(h(),g(e),e),r}b.lexical=p,b.isTruthy=v.isTruthy,b.isFalsy=v.isFalsy,b.evalExp=v.evalExp,b.evalValue=v.evalValue,b.Types={ParseError:x.ParseError,TokenizationEroor:x.TokenizationError,RenderBreakError:x.RenderBreakError,AssertionError:x.AssertionError},t.exports=b},{"./filters":1,"./src/filter.js":6,"./src/lexical.js":7,"./src/parser":9,"./src/render.js":10,"./src/scope":11,"./src/syntax.js":12,"./src/tag.js":13,"./src/tokenizer.js":14,"./src/util/assert.js":15,"./src/util/error.js":16,"./src/util/fs.js":17,"./src/util/promise.js":18,"./src/util/underscore.js":20,"./src/util/url.js":21,"./tags":33,path:4}],3:[function(e,t,r){},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){"use strict";var n,s,i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};s=function(){return function(){var e=arguments.length;if(0===e)throw new Error("resolveUrl requires at least one argument; got none.");var t=document.createElement("base");if(t.href=arguments[0],1===e)return t.href;var r=document.getElementsByTagName("head")[0];r.insertBefore(t,r.firstChild);for(var n,s=document.createElement("a"),i=1;i<e;i++)s.href=arguments[i],n=s.href,t.href=n;return r.removeChild(t),n}},"object"===((n=void 0)===r?"undefined":i(r))?t.exports=s():n.resolveUrl=s()},{}],6:[function(e,t,r){"use strict";var l=e("./lexical.js"),n=e("./syntax.js"),f=e("./util/assert.js"),s=e("./util/underscore.js"),p=new RegExp(""+l.value.source,"g");t.exports=function(a){a=s.assign({},a);var c={},t={render:function(e,t){var r=this.args.map(function(e){return n.evalValue(e,t)});return r.unshift(e),this.filter.apply(null,r)},parse:function(e){var t=l.filterLine.exec(e);f(t,"illegal filter: "+e);var r=t[1],n=t[2]||"",s=c[r];if("function"!=typeof s){if(a.strict_filters)throw new TypeError("undefined filter: "+r);return this.name=r,this.filter=function(e){return e},this.args=[],this}for(var i=[];t=p.exec(n.trim());){var o=t[0],u=new RegExp(o+"\\s*:","g").exec(t.input);u&&u.index===t.index?i.push("'"+o+"'"):i.push(o)}return this.name=r,this.filter=s,this.args=i,this}};return{construct:function(e){return Object.create(t).parse(e)},register:function(e,t){c[e]=t},clear:function(){c={}}}}},{"./lexical.js":7,"./syntax.js":12,"./util/assert.js":15,"./util/underscore.js":20}],7:[function(e,t,r){"use strict";var n=new RegExp(/'[^']*'/.source+"|"+/"[^"]*"/.source),s=new RegExp("(?:"+n.source+"|[^'\"])*"),i=/-?\d+/,o=/-?\d+\.?\d*|\.?\d+/,u=/true|false/,a=/[\w-]+[?]?/,c=new RegExp("\\[(?:"+n.source+"|[\\w-\\.]+)\\]"),l=new RegExp("(?:"+n.source+"|"+u.source+"|"+o.source+")"),f=new RegExp(a.source+"(?:\\."+a.source+"|"+c.source+")*"),p=new RegExp("(?:"+f.source+"|"+o.source+")"),h=new RegExp("\\("+p.source+"\\.\\."+p.source+"\\)"),g=new RegExp("\\(("+p.source+")\\.\\.("+p.source+")\\)"),d=new RegExp("(?:"+f.source+"|"+l.source+"|"+h.source+")"),v=new RegExp("(?:"+a.source+")\\s*:\\s*(?:"+d.source+")"),m=new RegExp("("+a.source+")\\s*:\\s*("+d.source+")","g"),y=new RegExp("^\\s*("+a.source+")\\s*([\\s\\S]*)\\s*$"),j=new RegExp("^"+l.source+"$","i"),x=new RegExp("^"+f.source+"$"),w=new RegExp("^"+o.source+"$"),b=new RegExp("^"+u.source+"$","i"),E=new RegExp("^"+n.source+"$"),T=new RegExp("^"+g.source+"$"),S=new RegExp("^"+i.source+"$"),k=new RegExp("(?:"+a.source+"\\s*:\\s*)?"+d.source),O=new RegExp(k.source+"(\\s*,\\s*"+k.source+")*"),R=new RegExp(a.source+"(?:\\s*:\\s*"+O.source+")?","g"),_=new RegExp("("+a.source+")(?:\\s*:\\s*("+O.source+"))?"),A=new RegExp("^"+_.source+"$");t.exports={quoted:n,number:o,bool:u,literal:l,filter:R,integer:i,hash:v,hashCapture:m,range:h,rangeCapture:g,identifier:a,value:d,quoteBalanced:s,operators:[/\s+or\s+/,/\s+and\s+/,/==|!=|<=|>=|<|>|\s+contains\s+/],quotedLine:E,numberLine:w,boolLine:b,rangeLine:T,literalLine:j,filterLine:A,tagLine:y,isLiteral:function(e){return j.test(e)},isVariable:function(e){return x.test(e)},parseLiteral:function(e){var t=e.match(w);if(t)return Number(e);if(t=e.match(b))return"true"===e.toLowerCase();if(t=e.match(E))return e.slice(1,-1);throw new TypeError("cannot parse '"+e+"' as literal")},isRange:function(e){return T.test(e)},matchValue:function(e){return d.exec(e)},isInteger:function(e){return S.test(e)}}},{}],8:[function(e,t,r){"use strict";t.exports=function(r){return{"==":function(e,t){return e===t},"!=":function(e,t){return e!==t},">":function(e,t){return null!==e&&null!==t&&t<e},"<":function(e,t){return null!==e&&null!==t&&e<t},">=":function(e,t){return null!==e&&null!==t&&t<=e},"<=":function(e,t){return null!==e&&null!==t&&e<=t},contains:function(e,t){return!!e&&("function"==typeof e.indexOf&&-1<e.indexOf(t))},and:function(e,t){return r(e)&&r(t)},or:function(e,t){return r(e)||r(t)}}}},{}],9:[function(e,t,r){"use strict";var u=e("./lexical.js"),a=e("./util/error.js").ParseError,c=e("./util/assert.js");t.exports=function(r,s){var t={init:function(e){return this.tokens=e,this.handlers={},this},on:function(e,t){return this.handlers[e]=t,this},trigger:function(e,t){var r=this.handlers[e];if("function"==typeof r)return r(t),!0},start:function(){var e;for(this.trigger("start");!this.stopRequested&&(e=this.tokens.shift());)if(!(this.trigger("token",e)||"tag"===e.type&&this.trigger("tag:"+e.name,e))){var t=n(e,this.tokens);this.trigger("template",t)}return this.stopRequested||this.trigger("end"),this},stop:function(){return this.stopRequested=!0,this}};function n(t,e){try{var r=null;return(r="tag"===t.type?i(t,e):"value"===t.type?o(t.value):t).token=t,r}catch(e){throw new a(e,t)}}function i(e,t){return"continue"===e.name||"break"===e.name?e:r.construct(e,t)}function o(e){var t=u.matchValue(e);c(t,"illegal value string: "+e);var r=t[0];e=e.substr(t.index+t[0].length);for(var n=[];t=u.filter.exec(e);)n.push([t[0].trim()]);return{type:"value",initial:r,filters:n.map(function(e){return s.construct(e)})}}return{parse:function(e){for(var t,r=[];t=e.shift();)r.push(n(t,e));return r},parseTag:i,parseStream:function(e){return Object.create(t).init(e)},parseValue:o}}},{"./lexical.js":7,"./util/assert.js":15,"./util/error.js":16}],10:[function(e,t,r){"use strict";var n=e("./syntax.js"),i=e("./util/promise.js").mapSeries,o=e("./util/error.js").RenderBreakError,s=e("./util/underscore.js"),u=e("./util/error.js").RenderError,a=e("./util/assert.js"),c={renderTemplates:function(e,r){var n=this;a(r,"unable to evalTemplates: scope undefined");var s="";return i(e,function(t){return function(e){return"tag"===e.type?this.renderTag(e,r).then(function(e){return void 0===e?"":e}):"value"===e.type?this.renderValue(e,r):Promise.resolve(e.value)}.call(n,t).then(function(e){return s+=e}).catch(function(e){if(e instanceof o)throw e.resolvedHTML=s,e;throw new u(e,t)})}).then(function(){return s})},renderTag:function(e,t){return"continue"===e.name?Promise.reject(new o("continue")):"break"===e.name?Promise.reject(new o("break")):e.render(t)},renderValue:function(e,t){var r=this;return Promise.resolve().then(function(){return r.evalValue(e,t)}).then(function(e){return void 0===e?"":s.stringify(e)})},evalValue:function(e,r){return a(r,"unable to evalValue: scope undefined"),e.filters.reduce(function(e,t){return t.render(e,r)},n.evalExp(e.initial,r))}};t.exports=function(){return Object.create(c)}},{"./syntax.js":12,"./util/assert.js":15,"./util/error.js":16,"./util/promise.js":18,"./util/underscore.js":20}],11:[function(e,t,r){"use strict";var i=e("./util/underscore.js"),u=e("./lexical.js"),a=e("./util/assert.js"),n={getAll:function(){return this.contexts.reduce(function(e,t){return Object.assign(e,t)},Object.create(null))},get:function(e){var r=this,t=this.propertyAccessSeq(e),n=this.findContextFor(t[0])||i.last(this.contexts);return t.reduce(function(e,t){return r.readProperty(e,t)},n)},set:function(e,r){var n=this.propertyAccessSeq(e),s=this.findContextFor(n[0])||i.last(this.contexts);n.some(function(e,t){return!i.isObject(s)||(t===n.length-1?(s[e]=r,!0):(void 0===s[e]&&(s[e]={}),void(s=s[e])))})},unshift:function(e){return this.contexts.unshift(e)},push:function(e){return this.contexts.push(e)},pop:function(t){if(!arguments.length)return this.contexts.pop();var e=this.contexts.findIndex(function(e){return e===t});if(-1===e)throw new TypeError("scope not found, cannot pop");return this.contexts.splice(e,1)[0]},findContextFor:function(e,t){t=t||function(){return!0};for(var r=this.contexts.length-1;0<=r;r--){var n=this.contexts[r];if(t(n)&&e in n)return n}return null},readProperty:function(e,t){var r=void 0;if(i.isNil(e)?r=void 0:("function"==typeof e.to_liquid?e=e.to_liquid():"function"==typeof e.toLiquid&&(e=e.toLiquid()),r="size"===t&&(i.isArray(e)||i.isString(e))?e.length:e[t]),i.isNil(r)&&this.opts.strict_variables)throw new TypeError("undefined variable: "+t);return r},propertyAccessSeq:function(e){e=String(e);for(var t=[],r="",n=void 0,s=0;s<e.length;)switch(e[s]){case"[":o();var i=e[s+1];/['"]/.test(i)?(n=e.indexOf(i,s+2),a(-1!==n,"unbalanced "+i+": "+e),r=e.slice(s+2,n),o(),s=n+2):(n=c(e,s+1),a(-1!==n,"unbalanced []: "+e),r=e.slice(s+1,n),u.isInteger(r)||(r=this.get(r)),o(),s=n+1);break;case".":o(),s++;break;default:r+=e[s],s++}if(o(),!t.length)throw new TypeError('invalid path:"'+e+'"');return t;function o(){r.length&&t.push(r),r=""}}};function c(e,t){for(var r=1,n=t;n<e.length;n++)if("["===e[n]&&r++,"]"===e[n]&&0===--r)return n;return-1}r.factory=function(e,t){var r=Object.create(n);return r.opts=i.assign({dynamicPartials:!0,strict_variables:!1,strict_filters:!1,blocks:{},root:[]},t),r.contexts=[e||{}],r},r.types={AssignScope:Object.create(null),CaptureScope:Object.create(null),IncrementScope:Object.create(null),DecrementScope:Object.create(null)}},{"./lexical.js":7,"./util/assert.js":15,"./util/underscore.js":20}],12:[function(e,t,r){"use strict";var h=e("./operators.js")(n),g=e("./lexical.js"),d=e("../src/util/assert.js");function v(e,t){if(e=e&&e.trim()){if(g.isLiteral(e))return g.parseLiteral(e);if(g.isVariable(e))return t.get(e);throw new TypeError("cannot eval '"+e+"' as value")}}function n(e){return!s(e)}function s(e){return!1===e||null==e}t.exports={evalExp:function e(t,r){d(r,"unable to evalExp: scope undefined");for(var n,s=g.operators,i=0;i<s.length;i++){var o=s[i],u=new RegExp("^("+g.quoteBalanced.source+")("+o.source+")("+g.quoteBalanced.source+")$");if(n=t.match(u)){var a=e(n[1],r);return(0,h[n[2].trim()])(a,e(n[3],r))}}if(n=t.match(g.rangeLine)){for(var c=v(n[1],r),l=v(n[2],r),f=[],p=c;p<=l;p++)f.push(p);return f}return v(t,r)},evalValue:v,isTruthy:n,isFalsy:s}},{"../src/util/assert.js":15,"./lexical.js":7,"./operators.js":8}],13:[function(e,t,r){"use strict";var o=e("./lexical.js"),u=e("./syntax.js"),i=e("./util/assert.js");t.exports=function(){var n={},s={render:function(e){var t=function(e,t){var r={},n=void 0;for(o.hashCapture.lastIndex=0;n=o.hashCapture.exec(e);){var s=n[1],i=n[2];r[s]=u.evalValue(i,t)}return r}(this.token.args,e),r=this.tagImpl;return"function"!=typeof r.render?Promise.resolve(""):Promise.resolve().then(function(){return r.render(e,t)})},parse:function(e,t){this.type="tag",this.token=e,this.name=e.name;var r=n[this.name];i(r,"tag "+this.name+" not found"),this.tagImpl=Object.create(r),this.tagImpl.parse&&this.tagImpl.parse(e,t)}};return{construct:function(e,t){var r=Object.create(s);return r.parse(e,t),r},register:function(e,t){n[e]=t},clear:function(){n={}}}}},{"./lexical.js":7,"./syntax.js":12,"./util/assert.js":15}],14:[function(e,t,r){"use strict";var m=e("./lexical.js"),y=e("./util/error.js").TokenizationError,j=e("./util/underscore.js"),x=e("./whitespace-ctrl.js"),w=e("./util/assert.js");r.parse=function(i,o,e){w(j.isString(i),"illegal input");for(var r,n,s,t,u,a,c,l=/({%-?([\s\S]*?)-?%})|({{-?([\s\S]*?)-?}})/g,f=0,p=(r=i,n=0,s=-1,{get:function(e){var t=r.slice(s+1,e).split("\n");return n+=t.length-1,s=e,n+1}}),h=0,g=[];t=l.exec(i);h=l.lastIndex)t.index>h&&g.push(v(h,t.index)),g.push(t[1]?d(t[1],t[2].trim(),t.index):(u=t[3],a=t[4].trim(),c=t.index,{type:"value",line:p.get(c),trim_left:"{{-"===u.slice(0,3),trim_right:"-}}"===u.slice(-3),raw:u,value:a,input:i,file:o}));return i.length>h&&g.push(v(h,i.length)),x(g,e),g;function d(e,t,r){var n=t.match(m.tagLine),s={type:"tag",indent:f,line:p.get(r),trim_left:"{%-"===e.slice(0,3),trim_right:"-%}"===e.slice(-3),raw:e,value:t,input:i,file:o};if(!n)throw new y("illegal tag syntax",s);return s.name=n[1],s.args=n[2],s}function v(e,t){var r=i.slice(e,t);return f=j.last(r.split("\n")).length,{type:"html",raw:r,value:r}}},r.whiteSpaceCtrl=x},{"./lexical.js":7,"./util/assert.js":15,"./util/error.js":16,"./util/underscore.js":20,"./whitespace-ctrl.js":22}],15:[function(e,t,r){"use strict";var n=e("./error.js").AssertionError;t.exports=function(e,t){if(!e)throw new n(t=t||"expect "+e+" to be true")}},{"./error.js":16}],16:[function(e,t,r){"use strict";var a=e("./underscore.js");function c(){this.name=this.constructor.name,Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}function n(e,t){c.call(this),this.input=t.input,this.line=t.line,this.file=t.file;var r,s,i,n,o,u=(r=t.input,s=t.line,i=r.split("\n"),n=Math.max(s-2,1),o=Math.min(s+3,i.length),a.range(n,o+1).map(function(e){return[e===s?">> ":" ",(t=e,r=o,n=t+"",Array((r+"").length-n.length).join(" ")+n),"| ",i[e-1]].join("");var t,r,n}).join("\n"));this.message=function(e,t){e=e||"",t.file&&(e+=", file:"+t.file);t.line&&(e+=", line:"+t.line);return e}(e.message,t),this.stack=u+"\n"+(this.stack||this.message)+(e.stack?"\nFrom "+e.stack:"")}function s(e,t){n.call(this,{message:e},t)}function i(e,t){a.assign(this,e),this.originalError=e,n.call(this,e,t)}function o(e,t){if(e instanceof o)return e;a.assign(this,e),this.originalError=e,n.call(this,e,t.token)}function u(e){c.call(this),this.message=e+""}function l(e){c.call(this),this.message=e+""}(s.prototype=Object.create(Error.prototype)).constructor=s,(i.prototype=Object.create(Error.prototype)).constructor=i,(o.prototype=Object.create(Error.prototype)).constructor=o,(u.prototype=Object.create(Error.prototype)).constructor=u,(l.prototype=Object.create(Error.prototype)).constructor=l,t.exports={TokenizationError:s,ParseError:i,RenderBreakError:u,AssertionError:l,RenderError:o}},{"./underscore.js":20}],17:[function(e,t,r){"use strict";var s=e("fs");t.exports={readFileAsync:function(e){return new Promise(function(r,n){s.readFile(e,"utf8",function(e,t){e?n(e):r(t)})})},statFileAsync:function(e){return new Promise(function(r,n){s.stat(e,function(e,t){return e?n(e):r(t)})})}}},{fs:3}],18:[function(e,t,r){"use strict";r.anySeries=function(n,s){var e=Promise.reject(new Error("init"));return n.forEach(function(t,r){e=e.catch(function(e){return s(t,r,n)})}),e},r.mapSeries=function(r,n){var s=Promise.resolve("init"),i=[];return r.forEach(function(e,t){s=s.then(function(){return n(e,t,r)}).then(function(e){return i.push(e)})}),s.then(function(){return i})}},{}],19:[function(e,t,r){"use strict";var n=["January","February","March","April","May","June","July","August","September","October","November","December"],s=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],i=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],o=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],u={1:"st",2:"nd",3:"rd",default:"th"},a={daysInMonth:function(e){return[31,a.isLeapYear(e)?29:28,31,30,31,30,31,31,30,31,30,31]},getDayOfYear:function(e){for(var t=0,r=0;r<e.getMonth();++r)t+=a.daysInMonth(e)[r];return t+e.getDate()},getWeekOfYear:function(e,t){var r=this.getDayOfYear(e)+(t-e.getDay()),n=7-new Date(e.getFullYear(),0,1).getDay()+t;return c.pad(Math.floor((r-n)/7)+1,2)},isLeapYear:function(e){var t=e.getFullYear();return!(0!=(3&t)||!(t%100||t%400==0&&t))},getSuffix:function(e){var t=e.getDate().toString(),r=parseInt(t.slice(-1));return u[r]||u.default},century:function(e){return parseInt(e.getFullYear().toString().substring(0,2),10)}},c={pad:function(e,t,r){r||(r="0");for(var n=e.toString(),s=t-n.length;0<s--;)n=r+n;return n}},l={a:function(e){return o[e.getDay()]},A:function(e){return i[e.getDay()]},b:function(e){return s[e.getMonth()]},B:function(e){return n[e.getMonth()]},c:function(e){return e.toLocaleString()},C:function(e){return a.century(e)},d:function(e){return c.pad(e.getDate(),2)},e:function(e){return c.pad(e.getDate(),2," ")},H:function(e){return c.pad(e.getHours(),2)},I:function(e){return c.pad(e.getHours()%12||12,2)},j:function(e){return c.pad(a.getDayOfYear(e),3)},k:function(e){return c.pad(e.getHours(),2," ")},l:function(e){return c.pad(e.getHours()%12||12,2," ")},L:function(e){return c.pad(e.getMilliseconds(),3)},m:function(e){return c.pad(e.getMonth()+1,2)},M:function(e){return c.pad(e.getMinutes(),2)},p:function(e){return e.getHours()<12?"AM":"PM"},P:function(e){return e.getHours()<12?"am":"pm"},q:function(e){return a.getSuffix(e)},s:function(e){return Math.round(e.valueOf()/1e3)},S:function(e){return c.pad(e.getSeconds(),2)},u:function(e){return e.getDay()||7},U:function(e){return a.getWeekOfYear(e,0)},w:function(e){return e.getDay()},W:function(e){return a.getWeekOfYear(e,1)},x:function(e){return e.toLocaleDateString()},X:function(e){return e.toLocaleTimeString()},y:function(e){return e.getFullYear().toString().substring(2,4)},Y:function(e){return e.getFullYear()},z:function(e){var t=e.getTimezoneOffset()/60*100;return(0<t?"-":"+")+c.pad(Math.abs(t),4)},"%":function(){return"%"}};l.h=l.b,l.N=l.L;t.exports=function(e,t){for(var r="",n=t;;){var s=/%./g,i=s.exec(n);if(!i)return r+n;r+=n.slice(0,s.lastIndex-2),n=n.slice(s.lastIndex);var o=i[0].charAt(1),u=l[o];r+=u?u.call(this,e):"%"+o}}},{}],20:[function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=Object.prototype.toString;function i(e){return"[object String]"===s.call(e)}function o(e){return null==e}function u(e){var t=void 0===e?"undefined":n(e);return null!=e&&("object"===t||"function"===t)}r.isString=i,r.isObject=u,r.isArray=function(e){return"[object Array]"===s.call(e)},r.isNil=o,r.isError=function(e){return"Error"===Object.prototype.toString.call(e).substr(-6,5)||"string"==typeof e.message&&"string"==typeof e.name},r.range=function(e,t,r){1===arguments.length&&(t=e,e=0),r=r||1;for(var n=[],s=e;s<t;s+=r)n.push(s);return n},r.last=function(e){return e[e.length-1]},r.forOwn=function(e,t){for(var r in e=e||{})if(e.hasOwnProperty(r)&&!1===t(e[r],r,e))break;return e},r.assign=function(t){return t=u(t)?t:{},Array.prototype.slice.call(arguments,1).forEach(function(e){return Object.assign(t,e)}),t},r.uniq=function(e){for(var t={},r=[],n=0,s=e.length;n<s;++n)t.hasOwnProperty(e[n])||(r.push(e[n]),t[e[n]]=1);return r},r.stringify=function e(t){if(o(t))return String(t);if("function"==typeof t.to_liquid)return e(t.to_liquid());if("function"==typeof t.toLiquid)return e(t.toLiquid());if(i(t))return t;var r=[];return JSON.stringify(t,function(e,t){if(u(t)){if(-1!==r.indexOf(t))return;r.push(t)}return t})}},{}],21:[function(e,t,r){"use strict";var n=e("resolve-url"),s=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^/]+?|)(\.[^./]*|))(?:[/]*)$/,i=/^(?:\w+:)?\/\/([^\s.]+\.\S{2}|localhost[:?\d]*)\S*$/,o=e("./underscore");r.extname=function(e){return s.exec(e).slice(1)[3]},r.valid=function(e){return i.test(e)},r.resolve=function(e,t){return"[object Array]"===Object.prototype.toString.call(e)&&(e=e[0]),e&&"/"!==o.last(e)&&(e+="/"),n(e,t)}},{"./underscore":20,"resolve-url":5}],22:[function(e,t,r){"use strict";var n=e("./util/underscore.js");t.exports=function(o,u){u=n.assign({greedy:!0},u);var a=!1;o.forEach(function(e,t){var r,n,s,i;s=e,i=u,!a&&("tag"===s.type?s.trim_left||i.trim_tag_left:"value"===s.type?s.trim_left||i.trim_value_left:void 0)&&function(e,t){if(e&&"html"===e.type){var r=t?/\s+$/g:/[\t\r ]*$/g;e.value=e.value.replace(r,"")}}(o[t-1],u.greedy),"tag"===e.type&&"raw"===e.name&&(a=!0),"tag"===e.type&&"endraw"===e.name&&(a=!1),r=e,n=u,!a&&("tag"===r.type?r.trim_right||n.trim_tag_right:"value"===r.type?r.trim_right||n.trim_value_right:void 0)&&function(e,t){if(e&&"html"===e.type){var r=t?/^\s+/g:/^[\t\r ]*\n?/g;e.value=e.value.replace(r,"")}}(o[t+1],u.greedy)})}},{"./util/underscore.js":20}],23:[function(e,t,r){"use strict";var n=e("..").lexical,s=new RegExp("("+n.identifier.source+")\\s*=(.*)"),i=e("../src/util/assert.js"),o=e("../src/scope").types;t.exports=function(r){r.registerTag("assign",{parse:function(e){var t=e.args.match(s);i(t,"illegal token "+e.raw),this.key=t[1],this.value=t[2]},render:function(e){var t=Object.create(o.AssignScope);return t[this.key]=r.evalValue(this.value,e),e.push(t),Promise.resolve("")}})}},{"..":2,"../src/scope":11,"../src/util/assert.js":15}],24:[function(e,t,r){"use strict";var n=e("..").lexical,o=new RegExp("("+n.identifier.source+")"),u=e("../src/util/assert.js"),s=e("../src/scope.js").types;t.exports=function(i){i.registerTag("capture",{parse:function(t,e){var r=this,n=t.args.match(o);u(n,t.args+" not valid identifier"),this.variable=n[1],this.templates=[];var s=i.parser.parseStream(e);s.on("tag:endcapture",function(e){return s.stop()}).on("template",function(e){return r.templates.push(e)}).on("end",function(e){throw new Error("tag "+t.raw+" not closed")}),s.start()},render:function(r,e){var n=this;return i.renderer.renderTemplates(this.templates,r).then(function(e){var t=Object.create(s.CaptureScope);t[n.variable]=e,r.push(t)})}})}},{"..":2,"../src/scope.js":11,"../src/util/assert.js":15}],25:[function(e,t,r){"use strict";var s=e("..");t.exports=function(i){i.registerTag("case",{parse:function(t,e){var r=this;this.cond=t.args,this.cases=[],this.elseTemplates=[];var n=[],s=i.parser.parseStream(e).on("tag:when",function(e){r.cases.push({val:e.args,templates:n=[]})}).on("tag:else",function(){return n=r.elseTemplates}).on("tag:endcase",function(e){return s.stop()}).on("template",function(e){return n.push(e)}).on("end",function(e){throw new Error("tag "+t.raw+" not closed")});s.start()},render:function(e,t){for(var r=0;r<this.cases.length;r++){var n=this.cases[r];if(s.evalExp(n.val,e)===s.evalExp(this.cond,e))return i.renderer.renderTemplates(n.templates,e)}return i.renderer.renderTemplates(this.elseTemplates,e)}})}},{"..":2}],26:[function(e,t,r){"use strict";t.exports=function(n){n.registerTag("comment",{parse:function(t,e){var r=n.parser.parseStream(e);r.on("token",function(e){"endcomment"===e.name&&r.stop()}).on("end",function(e){throw new Error("tag "+t.raw+" not closed")}),r.start()}})}},{}],27:[function(e,t,r){"use strict";var o=e(".."),n=o.lexical,s=new RegExp("^(?:("+n.value.source+")\\s*:\\s*)?(.*)$"),i=new RegExp(n.value.source,"g"),u=e("../src/util/assert.js");t.exports=function(e){e.registerTag("cycle",{parse:function(e,t){var r=s.exec(e.args);u(r,"illegal tag: "+e.raw),this.group=r[1]||"";var n=r[2];for(this.candidates=[];r=i.exec(n);)this.candidates.push(r[0]);u(this.candidates.length,"empty candidates: "+e.raw)},render:function(e,t){var r="cycle:"+o.evalValue(this.group,e)+":"+this.candidates.join(","),n=e.opts.groups=e.opts.groups||{},s=n[r];void 0===s&&(s=n[r]=0);var i=this.candidates[s];return s=(s+1)%this.candidates.length,n[r]=s,Promise.resolve(o.evalValue(i,e))}})}},{"..":2,"../src/util/assert.js":15}],28:[function(e,t,r){"use strict";var n=e("..").lexical,s=e("../src/util/assert.js"),i=e("../src/scope").types;t.exports=function(e){e.registerTag("decrement",{parse:function(e){var t=e.args.match(n.identifier);s(t,"illegal identifier "+e.args),this.variable=t[0]},render:function(e,t){var r=e.findContextFor(this.variable,function(e){return Object.getPrototypeOf(e)!==i.CaptureScope&&Object.getPrototypeOf(e)!==i.AssignScope});return r||(r=Object.create(i.DecrementScope),e.unshift(r)),"number"!=typeof r[this.variable]&&(r[this.variable]=0),--r[this.variable]}})}},{"..":2,"../src/scope":11,"../src/util/assert.js":15}],29:[function(e,t,r){"use strict";var c=e(".."),n=c.lexical,l=e("../src/util/promise.js").mapSeries,f=e("../src/util/underscore.js"),p=c.Types.RenderBreakError,o=e("../src/util/assert.js"),u=new RegExp("^("+n.identifier.source+")\\s+in\\s+("+n.value.source+")(?:\\s+"+n.hash.source+")*(?:\\s+(reversed))?(?:\\s+"+n.hash.source+")*$");t.exports=function(a){a.registerTag("for",{parse:function(e,t){var r,n=this,s=u.exec(e.args);o(s,"illegal tag: "+e.raw),this.variable=s[1],this.collection=s[2],this.reversed=!!s[3],this.templates=[],this.elseTemplates=[];var i=a.parser.parseStream(t).on("start",function(){return r=n.templates}).on("tag:else",function(){return r=n.elseTemplates}).on("tag:endfor",function(){return i.stop()}).on("template",function(e){return r.push(e)}).on("end",function(){throw new Error("tag "+e.raw+" not closed")});i.start()},render:function(t,e){var n=this,s=c.evalExp(this.collection,t);if(Array.isArray(s)||(f.isString(s)&&0<s.length?s=[s]:f.isObject(s)&&(s=Object.keys(s).map(function(e){return[e,s[e]]}))),!Array.isArray(s)||!s.length)return a.renderer.renderTemplates(this.elseTemplates,t);var r=e.offset||0,i=void 0===e.limit?s.length:e.limit;s=s.slice(r,r+i),this.reversed&&s.reverse();var o=s.map(function(e,t){var r={};return r[n.variable]=e,r.forloop={first:0===t,index:t+1,index0:t,last:t===s.length-1,length:s.length,rindex:s.length-t,rindex0:s.length-t-1},r}),u="";return l(o,function(e){return Promise.resolve().then(function(){return t.push(e)}).then(function(){return a.renderer.renderTemplates(n.templates,t)}).then(function(e){return u+=e}).catch(function(e){if(!(e instanceof p&&(u+=e.resolvedHTML,"continue"===e.message)))throw e}).then(function(){return t.pop(e)})}).catch(function(e){if(!(e instanceof p&&"break"===e.message))throw e}).then(function(){return u})}})}},{"..":2,"../src/util/assert.js":15,"../src/util/promise.js":18,"../src/util/underscore.js":20}],30:[function(e,t,r){"use strict";var o=e("..");t.exports=function(i){i.registerTag("if",{parse:function(t,e){var r,n=this;this.branches=[],this.elseTemplates=[];var s=i.parser.parseStream(e).on("start",function(){return n.branches.push({cond:t.args,templates:r=[]})}).on("tag:elsif",function(e){n.branches.push({cond:e.args,templates:r=[]})}).on("tag:else",function(){return r=n.elseTemplates}).on("tag:endif",function(e){return s.stop()}).on("template",function(e){return r.push(e)}).on("end",function(e){throw new Error("tag "+t.raw+" not closed")});s.start()},render:function(e,t){for(var r=0;r<this.branches.length;r++){var n=this.branches[r],s=o.evalExp(n.cond,e);if(o.isTruthy(s))return i.renderer.renderTemplates(n.templates,e)}return i.renderer.renderTemplates(this.elseTemplates,e)}})}},{"..":2}],31:[function(e,t,r){"use strict";var a=e(".."),c=a.lexical,n=new RegExp("with\\s+("+c.value.source+")"),s=/[^\s,]+/,l=e("../src/util/assert.js");t.exports=function(u){u.registerTag("include",{parse:function(e){var t=s.exec(e.args);t&&(this.staticValue=t[0]),(t=c.value.exec(e.args))&&(this.value=t[0]),(t=n.exec(e.args))&&(this.with=t[1])},render:function(t,r){var n=this,e=void 0;if(t.opts.dynamicPartials)if(c.quotedLine.exec(this.value)){var s=this.value.slice(1,-1);e=u.parseAndRender(s,t.getAll(),t.opts)}else e=Promise.resolve(a.evalValue(this.value,t));else e=Promise.resolve(this.staticValue);var i=t.opts.blocks,o=t.opts.blockMode;return e.then(function(e){return l(e,"cannot include with empty filename"),t.opts.blocks={},t.opts.blockMode="output",n.with&&(r[e]=a.evalValue(n.with,t)),u.getTemplate(e,t.opts.root)}).then(function(e){return t.push(r),u.renderer.renderTemplates(e,t)}).then(function(e){return t.pop(r),t.opts.blocks=i,t.opts.blockMode=o,e})}})}},{"..":2,"../src/util/assert.js":15}],32:[function(e,t,r){"use strict";var n=e(".."),s=e("../src/util/assert.js"),i=n.lexical,o=e("../src/scope").types;t.exports=function(e){e.registerTag("increment",{parse:function(e){var t=e.args.match(i.identifier);s(t,"illegal identifier "+e.args),this.variable=t[0]},render:function(e,t){var r=e.findContextFor(this.variable,function(e){return Object.getPrototypeOf(e)!==o.CaptureScope&&Object.getPrototypeOf(e)!==o.AssignScope});r||(r=Object.create(o.IncrementScope),e.unshift(r)),"number"!=typeof r[this.variable]&&(r[this.variable]=0);var n=r[this.variable];return r[this.variable]++,n}})}},{"..":2,"../src/scope":11,"../src/util/assert.js":15}],33:[function(t,e,r){"use strict";e.exports=function(e){t("./assign.js")(e),t("./capture.js")(e),t("./case.js")(e),t("./comment.js")(e),t("./cycle.js")(e),t("./decrement.js")(e),t("./for.js")(e),t("./if.js")(e),t("./include.js")(e),t("./increment.js")(e),t("./layout.js")(e),t("./raw.js")(e),t("./tablerow.js")(e),t("./unless.js")(e)}},{"./assign.js":23,"./capture.js":24,"./case.js":25,"./comment.js":26,"./cycle.js":27,"./decrement.js":28,"./for.js":29,"./if.js":30,"./include.js":31,"./increment.js":32,"./layout.js":34,"./raw.js":35,"./tablerow.js":36,"./unless.js":37}],34:[function(e,t,r){"use strict";var s=e(".."),n=s.lexical,o=e("../src/util/assert.js"),u=/\S+/;t.exports=function(i){i.registerTag("layout",{parse:function(e,t){var r=u.exec(e.args);r&&(this.staticLayout=r[0]),(r=n.value.exec(e.args))&&(this.layout=r[0]),this.tpls=i.parser.parse(t)},render:function(t,r){var n=t.opts.dynamicPartials?s.evalValue(this.layout,t):this.staticLayout;return o(n,"cannot apply layout with empty filename"),t.opts.blockMode="store",i.renderer.renderTemplates(this.tpls,t).then(function(e){return void 0===t.opts.blocks[""]&&(t.opts.blocks[""]=e),i.getTemplate(n,t.opts.root)}).then(function(e){return t.push(r),t.opts.blockMode="output",i.renderer.renderTemplates(e,t)}).then(function(e){return t.pop(r),e})}}),i.registerTag("block",{parse:function(e,t){var r=this,n=/\w+/.exec(e.args);this.block=n?n[0]:"",this.tpls=[];var s=i.parser.parseStream(t).on("tag:endblock",function(){return s.stop()}).on("template",function(e){return r.tpls.push(e)}).on("end",function(){throw new Error("tag "+e.raw+" not closed")});s.start()},render:function(t){var r=this;return Promise.resolve(t.opts.blocks[this.block]).then(function(e){return void 0===e?i.renderer.renderTemplates(r.tpls,t):e}).then(function(e){return"store"===t.opts.blockMode?(t.opts.blocks[r.block]=e,""):e})}})}},{"..":2,"../src/util/assert.js":15}],35:[function(e,t,r){"use strict";t.exports=function(s){s.registerTag("raw",{parse:function(e,t){var r=this;this.tokens=[];var n=s.parser.parseStream(t);n.on("token",function(e){"endraw"===e.name?n.stop():r.tokens.push(e)}).on("end",function(){throw new Error("tag "+e.raw+" not closed")}),n.start()},render:function(e,t){return this.tokens.map(function(e){return e.raw}).join("")}})}},{}],36:[function(e,t,r){"use strict";var p=e(".."),h=e("../src/util/promise.js").mapSeries,n=p.lexical,o=e("../src/util/assert.js"),u=new RegExp("^("+n.identifier.source+")\\s+in\\s+("+n.value.source+")(?:\\s+"+n.hash.source+")*$");t.exports=function(f){f.registerTag("tablerow",{parse:function(e,t){var r,n=this,s=u.exec(e.args);o(s,"illegal tag: "+e.raw),this.variable=s[1],this.collection=s[2],this.templates=[];var i=f.parser.parseStream(t).on("start",function(){return r=n.templates}).on("tag:endtablerow",function(e){return i.stop()}).on("template",function(e){return r.push(e)}).on("end",function(){throw new Error("tag "+e.raw+" not closed")});i.start()},render:function(r,e){var n,s,i=this,t=p.evalExp(this.collection,r)||[],o="",u=e.offset||0,a=void 0===e.limit?t.length:e.limit,c=e.cols;t=t.slice(u,u+a),c||(c=t.length);var l=t.map(function(e,t){var r={};return r[i.variable]=e,r});return h(l,function(t,e){return n=Math.floor(e/c)+1,1===(s=e%c+1)&&(1!==n&&(o+="</tr>"),o+='<tr class="row'+n+'">'),o+='<td class="col'+s+'">',r.push(t),f.renderer.renderTemplates(i.templates,r).then(function(e){return r.pop(t),o+=e,o+="</td>"})}).then(function(){return 0<n&&(o+="</tr>"),o})}})}},{"..":2,"../src/util/assert.js":15,"../src/util/promise.js":18}],37:[function(e,t,r){"use strict";var n=e("..");t.exports=function(i){i.registerTag("unless",{parse:function(t,e){var r,n=this;this.templates=[],this.elseTemplates=[];var s=i.parser.parseStream(e).on("start",function(e){r=n.templates,n.cond=t.args}).on("tag:else",function(){return r=n.elseTemplates}).on("tag:endunless",function(e){return s.stop()}).on("template",function(e){return r.push(e)}).on("end",function(e){throw new Error("tag "+t.raw+" not closed")});s.start()},render:function(e,t){var r=n.evalExp(this.cond,e);return n.isFalsy(r)?i.renderer.renderTemplates(this.templates,e):i.renderer.renderTemplates(this.elseTemplates,e)}})}},{"..":2}]},{},[2])(2)}); |
{ | ||
"name": "liquidjs", | ||
"version": "5.1.1", | ||
"version": "5.2.0", | ||
"description": "Liquid template engine by pure JavaScript: compatible to shopify, easy to extend.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -28,2 +28,3 @@ # liquidjs | ||
* 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). | ||
* Along with [.to_liquid()](https://github.com/Shopify/liquid/wiki/Introduction-to-Drops), we provide an alias `.toLiquid()` to align with your code styles. | ||
@@ -30,0 +31,0 @@ ## TOC |
const Syntax = require('./syntax.js') | ||
const mapSeries = require('./util/promise.js').mapSeries | ||
const RenderBreakError = require('./util/error.js').RenderBreakError | ||
const _ = require('./util/underscore.js') | ||
const RenderError = require('./util/error.js').RenderError | ||
@@ -30,5 +31,3 @@ const assert = require('./util/assert.js') | ||
} else if (template.type === 'value') { | ||
return Promise.resolve() | ||
.then(() => this.evalValue(template, scope)) | ||
.then(partial => partial === undefined ? '' : stringify(partial)) | ||
return this.renderValue(template, scope) | ||
} else { // template.type === 'html' | ||
@@ -50,2 +49,8 @@ return Promise.resolve(template.value) | ||
renderValue: function (template, scope) { | ||
return Promise.resolve() | ||
.then(() => this.evalValue(template, scope)) | ||
.then(partial => partial === undefined ? '' : _.stringify(partial)) | ||
}, | ||
evalValue: function (template, scope) { | ||
@@ -64,7 +69,2 @@ assert(scope, 'unable to evalValue: scope undefined') | ||
function stringify (val) { | ||
if (typeof val === 'string') return val | ||
return JSON.stringify(val) | ||
} | ||
module.exports = factory |
@@ -61,8 +61,16 @@ 'use strict' | ||
let val | ||
if (key === 'size' && (_.isArray(obj) || _.isString(obj))) { | ||
val = obj.length | ||
} else if (_.isNil(obj)) { | ||
if (_.isNil(obj)) { | ||
val = undefined | ||
} else { | ||
val = obj[key] | ||
if (typeof obj.to_liquid === 'function') { | ||
obj = obj.to_liquid() | ||
} else if (typeof obj.toLiquid === 'function') { | ||
obj = obj.toLiquid() | ||
} | ||
if (key === 'size' && (_.isArray(obj) || _.isString(obj))) { | ||
val = obj.length | ||
} else { | ||
val = obj[key] | ||
} | ||
} | ||
@@ -69,0 +77,0 @@ if (_.isNil(val) && this.opts.strict_variables) { |
@@ -0,1 +1,2 @@ | ||
'use strict' | ||
const toStr = Object.prototype.toString | ||
@@ -9,5 +10,31 @@ | ||
function isString (value) { | ||
return value instanceof String || typeof value === 'string' | ||
return toStr.call(value) === '[object String]' | ||
} | ||
function stringify (value) { | ||
if (isNil(value)) { | ||
return String(value) | ||
} | ||
if (typeof value.to_liquid === 'function') { | ||
return stringify(value.to_liquid()) | ||
} | ||
if (typeof value.toLiquid === 'function') { | ||
return stringify(value.toLiquid()) | ||
} | ||
if (isString(value)) { | ||
return value | ||
} | ||
let cache = [] | ||
return JSON.stringify(value, (key, value) => { | ||
if (isObject(value)) { | ||
if (cache.indexOf(value) !== -1) { | ||
return | ||
} | ||
cache.push(value) | ||
} | ||
return value | ||
}) | ||
} | ||
function isNil (value) { | ||
@@ -130,1 +157,2 @@ return value === null || value === undefined | ||
exports.uniq = uniq | ||
exports.stringify = stringify |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
695003
4897
247