shopify-liquid
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -11,3 +11,3 @@ var express = require('express'); | ||
app.engine('liquid', engine.express()); // register liquid engine | ||
app.set('views', __dirname); // specify the views directory | ||
app.set('views', ['./partials', './views']); // specify the views directory | ||
app.set('view engine', 'liquid'); // set to default | ||
@@ -14,0 +14,0 @@ |
@@ -7,2 +7,3 @@ { | ||
"scripts": { | ||
"start": "node index.js", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
@@ -9,0 +10,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Liquid=e()}}(function(){return function e(t,r,n){function s(o,u){if(!r[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[o]={exports:{}};t[o][0].call(l.exports,function(e){var r=t[o][1][e];return s(r?r:e)},l,l.exports,e,t,r,n)}return r[o].exports}for(var i="function"==typeof require&&require,o=0;o<n.length;o++)s(n[o]);return s}({1:[function(e,t){"use strict";function r(e){return o(e).replace(/&|<|>|"|'/g,function(e){return f[e]})}function n(e){return o(e).replace(/&(amp|lt|gt|#34|#39);/g,function(e){return p[e]})}function s(e){var t=(e+"").split(".");return t.length>1?t[1].length:0}function i(e,t){return Math.max(s(e),s(t))}function o(e){return e=e||"",e+""}function u(e){return function(t,r){var n=i(t,r);return e(t,r).toFixed(n)}}function a(e){return l.forOwn(h,function(t,r){return e.registerFilter(r,t)})}var c=e("./src/util/strftime.js"),l=e("./src/util/underscore.js"),f={"&":"&","<":"<",">":">",'"':""","'":"'"},p={"&":"&","<":"<",">":">",""":'"',"'":"'"},h={abs:function(e){return Math.abs(e)},append:function(e,t){return e+t},capitalize:function(e){return o(e).charAt(0).toUpperCase()+e.slice(1)},ceil:function(e){return Math.ceil(e)},date:function(e,t){return"now"===e&&(e=new Date),c(e,t)},"default":function(e,t){return t||e},divided_by:function(e,t){return Math.floor(e/t)},downcase:function(e){return e.toLowerCase()},escape:r,escape_once:function(e){return r(n(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 e[e.length-1]},lstrip:function(e){return o(e).replace(/^\s+/,"")},map:function(e,t){return e.map(function(e){return e[t]})},minus:u(function(e,t){return e-t}),modulo:u(function(e,t){return e%t}),newline_to_br:function(e){return e.replace(/\n/g,"<br />")},plus:u(function(e,t){return e+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 o(e).split(t).join(r)},replace_first:function(e,t,r){return o(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 o(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 o(e).split(t)},strip:function(e){return o(e).trim()},strip_html:function(e){return o(e).replace(/<\/?\s*\w+\s*\/?>/g,"")},strip_newlines:function(e){return o(e).replace(/\n/g,"")},times:function(e,t){return e*t},truncate:function(e,t,r){return e=o(e),r=void 0===r?"...":r,t=t||16,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)?!1:(t[e]=!0,!0)})},upcase:function(e){return o(e).toUpperCase()},url_encode:encodeURIComponent};a.filters=h,t.exports=a},{"./src/util/strftime.js":20,"./src/util/underscore.js":21}],2:[function(e,t){"use strict";function r(e){e=i.assign({},e),e.root=n(e.root),e.root.length||(e.root=["."]),e.extname=e.extname||".liquid";var t=Object.create(b);return t.init(h(),g(),e),t}function n(e){return i.isArray(e)?e:i.isString(e)?[e]:[]}var s=e("./src/scope"),i=e("./src/util/underscore.js"),o=e("./src/util/assert.js"),u=e("./src/tokenizer.js"),a=e("./src/util/fs.js").statFileAsync,c=e("./src/util/fs.js").readFileAsync,l=e("./src/util/fs.js").pathResolve,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"),x=e("./filters"),y=e("any-promise"),w=e("./src/util/promise.js").anySeries,j=e("./src/util/error.js"),b={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),x(this),this},parse:function(e){var t=u.parse(e);return this.parser.parse(t)},render:function(e,t,r){r=i.assign({strict_variables:!1,strict_filters:!1,root:[]},r),this.renderer.initRegister(r);var n=s.factory(t,{strict:r.strict_variables});return this.renderer.renderTemplates(e,n)},parseAndRender:function(e,t,r){var n=this;return y.resolve().then(function(){return n.parse(e)}).then(function(e){return n.render(e,t,r)})["catch"](function(e){if(e instanceof j.RenderBreak)return e.html;throw e})},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)})["catch"](function(t){throw t.file=e,t})},evalOutput:function(e,t){var r=this.parser.parseOutput(e.trim());return this.renderer.evalOutput(r,t)},registerFilter:function(e,t){return this.filter.register(e,t)},registerTag:function(e,t){return this.tag.register(e,t)},lookup:function(e,t){t=this.options.root.concat(t||[]);var r=t.map(function(t){return l(t,e)});return w(r,function(e){return a(e).then(function(){return e})})["catch"](function(r){throw"ENOENT"===r.code&&(r.message="Failed to lookup "+e+" in: "+t),r})},getTemplate:function(e,t){var r=this;return e.match(/\.\w+$/)||(e+=this.options.extname),this.lookup(e,t).then(function(e){if(r.options.cache){var t=r.cache[e];return t?y.resolve(t):c(e).then(function(e){return r.parse(e)}).then(function(t){return r.cache[e]=t})}return c(e).then(function(e){return r.parse(e)})})},express:function(e){e=e||{};var t=this;return function(r,n,s){o(i.isArray(this.root),"illegal views root, are you using express.js?"),e.root=this.root,t.renderFile(r,n,e).then(function(e){return s(null,e)})["catch"](function(e){return s(e)})}}};r.lexical=p,r.isTruthy=v.isTruthy,r.isFalsy=v.isFalsy,r.evalExp=v.evalExp,r.evalValue=v.evalValue,r.Types={ParseError:j.ParseError,TokenizationEroor:j.TokenizationError,RenderBreak:j.RenderBreak,AssertionError:j.AssertionError},t.exports=r},{"./filters":1,"./src/filter.js":7,"./src/lexical.js":8,"./src/parser":10,"./src/render.js":11,"./src/scope":12,"./src/syntax.js":13,"./src/tag.js":14,"./src/tokenizer.js":15,"./src/util/assert.js":16,"./src/util/error.js":17,"./src/util/fs.js":18,"./src/util/promise.js":19,"./src/util/underscore.js":21,"./tags":32,"any-promise":3}],3:[function(e,t){"use strict";t.exports=e("./register")().Promise},{"./register":5}],4:[function(e,t){"use strict";var r="@@any-promise/REGISTRATION",n=null;t.exports=function(e,t){return function(s,i){s=s||null,i=i||{};var o=i.global!==!1;if(null===n&&o&&(n=e[r]||null),null!==n&&null!==s&&n.implementation!==s)throw new Error('any-promise already defined as "'+n.implementation+'". You can only register an implementation before the first call to require("any-promise") and an implementation cannot be changed');return null===n&&(n=null!==s&&"undefined"!=typeof i.Promise?{Promise:i.Promise,implementation:s}:t(s),o&&(e[r]=n)),n}}},{}],5:[function(e,t){"use strict";function r(){if("undefined"==typeof window.Promise)throw new Error("any-promise browser requires a polyfill or explicit registration e.g: require('any-promise/register/bluebird')");return{Promise:window.Promise,implementation:"window.Promise"}}t.exports=e("./loader")(window,r)},{"./loader":4}],6:[function(){"use strict"},{}],7:[function(e,t){"use strict";var r=e("./lexical.js"),n=e("./syntax.js"),s=e("./util/assert.js"),i=new RegExp(""+r.value.source,"g");t.exports=function(){function e(e){var t=Object.create(a);return t.parse(e)}function t(e,t){u[e]=t}function o(){u={}}var u={},a={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=r.filterLine.exec(e);s(t,"illegal filter: "+e);var n=t[1],o=t[2]||"",a=u[n];if("function"!=typeof a)return{name:n,error:new Error("undefined filter: "+n)};for(var c=[];t=i.exec(o.trim());)c.push(t[0]);return this.name=n,this.filter=a,this.args=c,this}};return{construct:e,register:t,clear:o}}},{"./lexical.js":8,"./syntax.js":13,"./util/assert.js":16}],8:[function(e,t){"use strict";function r(e){return F.test(e)}function n(e){return R.test(e)}function s(e){return P.test(e)}function i(e){return S.test(e)}function o(e){return b.exec(e)}function u(e){var t;return(t=e.match(O))?Number(e):(t=e.match(M))?"true"===e.toLowerCase():(t=e.match(L))?e.slice(1,-1):void 0}var a=/'[^']*'/,c=/"[^"]*"/,l=new RegExp(a.source+"|"+c.source),f=new RegExp("(?:"+l.source+"|[^'\"])*"),p=/-?\d+/,h=/-?\d+\.?\d*|\.?\d+/,g=/true|false/,d=/[\w-]+/,v=new RegExp("\\[(?:"+l.source+"|[\\w-\\.]+)\\]"),m=new RegExp("(?:"+l.source+"|"+g.source+"|"+h.source+")"),x=new RegExp(d.source+"(?:\\."+d.source+"|"+v.source+")*"),y=new RegExp("(?:"+x.source+"|"+h.source+")"),w=new RegExp("\\("+y.source+"\\.\\."+y.source+"\\)"),j=new RegExp("\\(("+y.source+")\\.\\.("+y.source+")\\)"),b=new RegExp("(?:"+x.source+"|"+m.source+"|"+w.source+")"),E=new RegExp("(?:"+d.source+")\\s*:\\s*(?:"+b.source+")"),T=new RegExp("("+d.source+")\\s*:\\s*("+b.source+")","g"),k=new RegExp("^\\s*("+d.source+")\\s*(.*)\\s*$"),R=new RegExp("^"+m.source+"$","i"),S=new RegExp("^"+x.source+"$"),O=new RegExp("^"+h.source+"$"),M=new RegExp("^"+g.source+"$","i"),L=new RegExp("^"+l.source+"$"),P=new RegExp("^"+j.source+"$"),F=new RegExp("^"+p.source+"$"),A=new RegExp(b.source+"(\\s*,\\s*"+b.source+")*"),q=new RegExp(d.source+"(?:\\s*:\\s*"+A.source+")?","g"),D=new RegExp("("+d.source+")(?:\\s*:\\s*("+A.source+"))?"),I=new RegExp("^"+D.source+"$"),_=[/\s+or\s+/,/\s+and\s+/,/==|!=|<=|>=|<|>|\s+contains\s+/];t.exports={quoted:l,number:h,bool:g,literal:m,filter:q,integer:p,hash:E,hashCapture:T,range:w,rangeCapture:j,identifier:d,value:b,quoteBalanced:f,operators:_,quotedLine:L,numberLine:O,boolLine:M,rangeLine:P,literalLine:R,filterLine:I,tagLine:k,isLiteral:n,isVariable:i,parseLiteral:u,isRange:s,matchValue:o,isInteger:r}},{}],9:[function(e,t){"use strict";var r={"==":function(e,t){return e==t},"!=":function(e,t){return e!=t},">":function(e,t){return e>t},"<":function(e,t){return t>e},">=":function(e,t){return e>=t},"<=":function(e,t){return t>=e},contains:function(e,t){return e.indexOf(t)>-1},and:function(e,t){return e&&t},or:function(e,t){return e||t}};t.exports=r},{}],10:[function(e,t){"use strict";var r=e("./lexical.js"),n=e("./util/error.js").ParseError,s=e("./util/assert.js");t.exports=function(e,t){function i(e){for(var t,r=[];t=e.shift();)r.push(o(t,e));return r}function o(e,t){try{switch(e.type){case"tag":return u(e,t);case"output":return a(e.value);case"html":return e}}catch(r){throw new n(r.message,e.input,e.line,r)}}function u(t,r){return"continue"===t.name||"break"===t.name?t:e.construct(t,r)}function a(e){var n=r.matchValue(e);s(n,"illegal output string: "+e);var i=n[0];e=e.substr(n.index+n[0].length);for(var o=[];n=r.filter.exec(e);)o.push([n[0].trim()]);return{type:"output",initial:i,filters:o.map(function(e){return t.construct(e)})}}function c(e){var t=Object.create(l);return t.init(e)}var l={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];return"function"==typeof r?(r(t),!0):void 0},start:function(){this.trigger("start");for(var e;!this.stopRequested&&(e=this.tokens.shift());)if(!(this.trigger("token",e)||"tag"==e.type&&this.trigger("tag:"+e.name,e))){var t=o(e,this.tokens);this.trigger("template",t)}return this.stopRequested||this.trigger("end"),this},stop:function(){return this.stopRequested=!0,this}};return{parse:i,parseTag:u,parseStream:c,parseOutput:a}}},{"./lexical.js":8,"./util/assert.js":16,"./util/error.js":17}],11:[function(e,t){"use strict";function r(){var e=Object.create(c);return e.register={},e}function n(e){return"string"==typeof e?e:JSON.stringify(e)}var s=e("./syntax.js"),i=e("any-promise"),o=e("./util/promise.js").mapSeries,u=e("./util/error.js").RenderBreak,a=e("./util/assert.js"),c={renderTemplates:function(e,t){function r(e){return"tag"===e.type?this.renderTag(e,t).then(function(e){return void 0===e?"":e}):"output"===e.type?i.resolve(this.evalOutput(e,t)).then(function(e){return void 0===e?"":n(e)}):i.resolve(e.value)}var s=this;a(t,"unable to evalTemplates: scope undefined");var c="";return o(e,function(e){return r.call(s,e).then(function(e){return c+=e})["catch"](function(e){throw e instanceof u&&(e.resolvedHTML=c),e})}).then(function(){return c})},renderTag:function(e,t){return"continue"===e.name?i.reject(new u("continue")):"break"===e.name?i.reject(new u("break")):e.render(t,this.register)},evalOutput:function(e,t){var r=this;a(t,"unable to evalOutput: scope undefined");var n=s.evalExp(e.initial,t);return e.filters.some(function(e){if(e.error){if(r.register.strict_filters)throw e.error;return n="",!0}n=e.render(n,t)}),n},initRegister:function(e){return this.register=e}};t.exports=r},{"./syntax.js":13,"./util/assert.js":16,"./util/error.js":17,"./util/promise.js":19,"any-promise":3}],12:[function(e,t,r){"use strict";function n(e,t){for(var r=1,n=t;n<e.length;n++)if("["===e[n]&&r++,"]"===e[n]&&(r--,0===r))return n;return-1}var s=e("./util/underscore.js"),i=e("./lexical.js"),o=e("./util/assert.js"),u={safeGet:function(e){var t;if(void 0===e){var r={};for(t=this.scopes.length-1;t>=0;t--){var n=this.scopes[t];for(var s in n)n.hasOwnProperty(s)&&(r[s]=n[s])}return r}for(t=this.scopes.length-1;t>=0;t--){var i=this.getPropertyByPath(this.scopes[t],e);if(void 0!==i)return i}},get:function(e){var t=this.safeGet(e);if(void 0===t&&this.opts.strict)throw new Error("[strict_variables] undefined variable: "+e);return t},set:function(e,t){return this.setPropertyByPath(this.scopes[this.scopes.length-1],e,t),this},push:function(e){return o(e,"trying to push "+e+" into scopes"),this.scopes.push(e)},pop:function(){return this.scopes.pop()},unshift:function(e){return o(e,"trying to push "+e+" into scopes"),this.scopes.unshift(e)},shift:function(){return this.scopes.shift()},setPropertyByPath:function(e,t,r){if(s.isString(t))for(var n=t.replace(/\[/g,".").replace(/\]/g,"").split("."),i=0;i<n.length;i++){var o=n[i];if(i===n.length-1)return e[o]=r;void 0===e[o]&&(e[o]={}),e=e[o]||{}}},getPropertyByPath:function(e,t){if(s.isString(t)&&t.length){var r=this.propertyAccessSeq(t);return r.forEach(function(t){return e=e&&e[t]}),e}return e[t]},propertyAccessSeq:function(e){for(var t=[],r="",s=0;s<e.length;s++)if("["===e[s]){t.push(r),r="";var u=e[s+1];if("'"!==u&&'"'!==u){var a=n(e,s+1);o(-1!==a,"unbalanced []: "+e),r=e.slice(s+1,a),t.push(i.isInteger(r)?r:this.get(r)),r="",s=a}else{var a=e.indexOf(u,s+2);o(-1!==a,"unbalanced "+u+": "+e),r=e.slice(s+2,a),t.push(r),r="",s=a+1}}else"."===e[s]?(t.push(r),r=""):r+=e[s];return r.length&&t.push(r),t}};r.factory=function(e,t){t=s.assign({strict:!1},t);var r=Object.create(u);return r.opts=t,r.scopes=[e||{}],r}},{"./lexical.js":8,"./util/assert.js":16,"./util/underscore.js":21}],13:[function(e,t){"use strict";function r(e,t){a(t,"unable to evalExp: scope undefined");for(var s,i=u.operators,c=0;c<i.length;c++){var l=i[c],f=new RegExp("^("+u.quoteBalanced.source+")("+l.source+")("+u.quoteBalanced.source+")$");if(s=e.match(f)){var p=r(s[1],t),h=o[s[2].trim()],g=r(s[3],t);return h(p,g)}}if(s=e.match(u.rangeLine)){for(var d=n(s[1],t),v=n(s[2],t),m=[],x=d;v>=x;x++)m.push(x);return m}return n(e,t)}function n(e,t){return e=e&&e.trim(),e?u.isLiteral(e)?u.parseLiteral(e):u.isVariable(e)?t.get(e):void 0:void 0}function s(e){return e instanceof Array?!!e.length:!!e}function i(e){return!s(e)}var o=e("./operators.js"),u=e("./lexical.js"),a=e("../src/util/assert.js");t.exports={evalExp:r,evalValue:n,isTruthy:s,isFalsy:i}},{"../src/util/assert.js":16,"./lexical.js":8,"./operators.js":9}],14:[function(e,t){"use strict";function r(e,t){var r,s={};for(n.hashCapture.lastIndex=0;r=n.hashCapture.exec(e);){var o=r[1],u=r[2];s[o]=i.evalValue(u,t)}return s}var n=e("./lexical.js"),s=e("any-promise"),i=e("./syntax.js"),o=e("./util/assert.js");t.exports=function(){function e(e,t){i[e]=t}function t(e,t){var r=Object.create(u);return r.parse(e,t),r}function n(){i={}}var i={},u={render:function(e,t){var n=r(this.token.args,e);return this.tagImpl.render&&this.tagImpl.render(e,n,t)||s.resolve("")},parse:function(e,t){this.type="tag",this.token=e,this.name=e.name;var r=i[this.name];o(r,"tag "+this.name+" not found"),this.tagImpl=Object.create(r),this.tagImpl.parse&&this.tagImpl.parse(e,t)}};return{construct:t,register:e,clear:n}}},{"./lexical.js":8,"./syntax.js":13,"./util/assert.js":16,"any-promise":3}],15:[function(e,t,r){"use strict";function n(e){function t(e,t,s){return{type:e,raw:s[t],value:s[t+1].trim(),line:n(s),input:r(s)}}function r(e){var t=e.input.lastIndexOf("\n",e.index),r=e.input.indexOf("\n",e.index);return-1===r&&(r=e.input.length),e.input.slice(t+1,r)}function n(e){var t=e.input.slice(g+1,e.index).split("\n");return d+=t.length-1,g=e.index,d+1}var a=[];u(o.isString(e),new i("illegal input type"));for(var c,l,f,p=/({%(.*?)%})|({{(.*?)}})/g,h=0,g=-1,d=0;null!==(c=p.exec(e));){if(c.index>h&&(l=e.slice(h,c.index),a.push({type:"html",raw:l,value:l})),c[1]){f=t("tag",1,c);var v=f.value.match(s.tagLine);if(!v)throw new i("illegal tag: "+f.raw,f.input,f.line);f.name=v[1],f.args=v[2],a.push(f)}else f=t("output",3,c),a.push(f);h=p.lastIndex}return e.length>h&&(l=e.slice(h,e.length),a.push({type:"html",raw:l,value:l})),a}var s=e("./lexical.js"),i=e("./util/error.js").TokenizationError,o=e("./util/underscore.js"),u=e("../src/util/assert.js");r.parse=n},{"../src/util/assert.js":16,"./lexical.js":8,"./util/error.js":17,"./util/underscore.js":21}],16:[function(e,t){"use strict";function r(e,t){if(!e){if(t instanceof Error)throw t;var t=t||"expect "+e+" to be true";throw new n(t)}}var n=e("./error.js").AssertionError;t.exports=r},{"./error.js":17}],17:[function(e,t){"use strict";function r(e,t,r){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.message=e,this.input=t,this.line=r}function n(e,t,r,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.originalError=n,this.message=e,this.input=t,this.line=r}function s(e){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.message=e}function i(e){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.message=e}r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,s.prototype=Object.create(Error.prototype),s.prototype.constructor=s,i.prototype=Object.create(Error.prototype),i.prototype.constructor=i,t.exports={TokenizationError:r,ParseError:n,RenderBreak:s,AssertionError:i}},{}],18:[function(e,t){"use strict";function r(e){return new Promise(function(t,r){i.readFile(e,"utf8",function(e,n){e?r(e):t(n)})})}function n(e){return new Promise(function(t,r){i.stat(e,function(e,n){return e?r(e):t(n)})})}function s(e,t){if("/"==t[0])return t;var r=e.split("/").concat(t.split("/")),n=[];return r.forEach(function(e){".."==e?n.pop():e&&"."!=e&&n.push(e)}),"/"+n.join("/")}var i=e("fs");t.exports={readFileAsync:r,pathResolve:s,statFileAsync:n}},{fs:6}],19:[function(e,t,r){"use strict";function n(e,t){var r=i.reject(new Error("init"));return e.forEach(function(n,s){r=r["catch"](function(){return t(n,s,e)})}),r}function s(e,t){var r=i.resolve("init"),n=[];return e.forEach(function(s,i){r=r.then(function(){return t(s,i,e)}).then(function(e){return n.push(e)})}),r.then(function(){return n})}var i=e("any-promise");r.anySeries=n,r.mapSeries=s},{"any-promise":3}],20:[function(e,t){"use strict";var r=["January","February","March","April","May","June","July","August","September","October","November","December"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],s=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],i=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],o={1:"st",2:"nd",3:"rd","default":"th"},u={daysInMonth:function(e){var t=u.isLeapYear(e)?29:28;return[31,t,31,30,31,30,31,31,30,31,30,31]},getDayOfYear:function(e){for(var t=0,r=0;r<e.getMonth();++r)t+=u.daysInMonth(e)[r];return t+e.getDate()},getWeekOfYear:function(e,t){var r=this.getDayOfYear(e)+(t-e.getDay()),n=new Date(e.getFullYear(),0,1),s=7-n.getDay()+t;return a.pad(Math.floor((r-s)/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 o[r]||o["default"]},century:function(e){return parseInt(e.getFullYear().toString().substring(0,2),10)}},a={pad:function f(e,t,r){r||(r="0");for(var n=e.toString(),f=t-n.length;f-->0;)n=r+n;return n}},c={a:function(e){return i[e.getDay()]},A:function(e){return s[e.getDay()]},b:function(e){return n[e.getMonth()]},B:function(e){return r[e.getMonth()]},c:function(e){return e.toLocaleString()},C:function(e){return u.century(e)},d:function(e){return a.pad(e.getDate(),2)},e:function(e){return a.pad(e.getDate(),2," ")},H:function(e){return a.pad(e.getHours(),2)},I:function(e){return a.pad(e.getHours()%12||12,2)},j:function(e){return a.pad(u.getDayOfYear(e),3)},k:function(e){return a.pad(e.getHours(),2," ")},l:function(e){return a.pad(e.getHours()%12||12,2," ")},L:function(e){return a.pad(e.getMilliseconds(),3)},m:function(e){return a.pad(e.getMonth()+1,2)},M:function(e){return a.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 u.getSuffix(e)},s:function(e){return Math.round(e.valueOf()/1e3)},S:function(e){return a.pad(e.getSeconds(),2)},u:function(e){return e.getDay()||7},U:function(e){return u.getWeekOfYear(e,0)},w:function(e){return e.getDay()},W:function(e){return u.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(t>0?"-":"+")+a.pad(Math.abs(t),4)},"%":function(){return"%"}};c.h=c.b,c.N=c.L;var l=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=c[o];r+=u?u.call(this,e):"%"+o}};t.exports=l},{}],21:[function(e,t,r){"use strict";function n(e){return e instanceof String||"string"==typeof e}function s(e,t){e=e||{};for(var r in e)if(e.hasOwnProperty(r)&&t(e[r],r,e)===!1)break;return e}function i(e,t){return e=e||{},s(t,function(t,r){e[r]=t}),e}function o(e){return e instanceof Array}r.isString=n,r.isArray=o,r.forOwn=s,r.assign=i},{}],22:[function(e,t){"use strict";var r=e(".."),n=r.lexical,s=e("any-promise"),i=new RegExp("("+n.identifier.source+")\\s*=(.*)"),o=e("../src/util/assert.js");t.exports=function(e){e.registerTag("assign",{parse:function(e){var t=e.args.match(i);o(t,"illegal token "+e.raw),this.key=t[1],this.value=t[2]},render:function(t){return t.set(this.key,e.evalOutput(this.value,t)),s.resolve("")}})}},{"..":2,"../src/util/assert.js":16,"any-promise":3}],23:[function(e,t){"use strict";var r=e(".."),n=r.lexical,s=new RegExp("("+n.identifier.source+")"),i=e("../src/util/assert.js");t.exports=function(e){e.registerTag("capture",{parse:function(t,r){var n=this,o=t.args.match(s);i(o,t.args+" not valid identifier"),this.variable=o[1],this.templates=[];var u=e.parser.parseStream(r);u.on("tag:endcapture",function(){return u.stop()}).on("template",function(e){return n.templates.push(e)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")}),u.start()},render:function(t){var r=this;return e.renderer.renderTemplates(this.templates,t).then(function(e){t.set(r.variable,e)})}})}},{"..":2,"../src/util/assert.js":16}],24:[function(e,t){"use strict";{var r=e("..");e("../src/util/assert.js")}t.exports=function(e){e.registerTag("case",{parse:function(t,r){var n=this;this.cond=t.args,this.cases=[],this.elseTemplates=[];var s=[],i=e.parser.parseStream(r).on("tag:when",function(e){n.cases[e.args]||n.cases.push({val:e.args,templates:s=[]})}).on("tag:else",function(){return s=n.elseTemplates}).on("tag:endcase",function(){return i.stop()}).on("template",function(e){return s.push(e)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});i.start()},render:function(t){for(var n=0;n<this.cases.length;n++){var s=this.cases[n],i=r.evalExp(s.val,t),o=r.evalExp(this.cond,t);if(i===o)return e.renderer.renderTemplates(s.templates,t)}return e.renderer.renderTemplates(this.elseTemplates,t)}})}},{"..":2,"../src/util/assert.js":16}],25:[function(e,t){"use strict";t.exports=function(e){e.registerTag("comment",{parse:function(t,r){var n=e.parser.parseStream(r);n.on("token",function(e){"endcomment"===e.name&&n.stop()}).on("end",function(){throw new Error("tag "+t.raw+" not closed")}),n.start()}})}},{}],26:[function(e,t){"use strict";var r=e(".."),n=e("any-promise"),s=r.lexical,i=new RegExp("^(?:("+s.value.source+")\\s*:\\s*)?(.*)$"),o=new RegExp(s.value.source,"g"),u=e("../src/util/assert.js");t.exports=function(e){e.registerTag("cycle",{parse:function(e){var t=i.exec(e.args);u(t,"illegal tag: "+e.raw),this.group=t[1]||"";var r=t[2];for(this.candidates=[];t=o.exec(r);)this.candidates.push(t[0]);u(this.candidates.length,"empty candidates: "+e.raw)},render:function(e,t,s){var i=r.evalValue(this.group,e),o="cycle:"+i+":"+this.candidates.join(","),u=s[o];void 0===u&&(u=s[o]=0);var a=this.candidates[u];return u=(u+1)%this.candidates.length,s[o]=u,n.resolve(r.evalValue(a,e))}})}},{"..":2,"../src/util/assert.js":16,"any-promise":3}],27:[function(e,t){"use strict";var r=e(".."),n=r.lexical,s=e("../src/util/assert.js");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){var t=e.get(this.variable);"number"!=typeof t&&(t=0),e.set(this.variable,t-1)}})}},{"..":2,"../src/util/assert.js":16}],28:[function(e,t){"use strict";var r=e(".."),n=(e("any-promise"),r.lexical),s=e("../src/util/promise.js").mapSeries,i=r.Types.RenderBreak,o=e("../src/util/assert.js"),u=new RegExp("^("+n.identifier.source+")\\s+in\\s+"+("("+n.value.source+")")+("(?:\\s+"+n.hash.source+")*")+"(?:\\s+(reversed))?$");t.exports=function(e){e.registerTag("for",{parse:function(t,r){var n=this,s=u.exec(t.args);o(s,"illegal tag: "+t.raw),this.variable=s[1],this.collection=s[2],this.reversed=!!s[3],this.templates=[],this.elseTemplates=[];var i,a=e.parser.parseStream(r).on("start",function(){return i=n.templates}).on("tag:else",function(){return i=n.elseTemplates}).on("tag:endfor",function(){return a.stop()}).on("template",function(e){return i.push(e)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});a.start()},render:function(t,n){var o=this,u=r.evalExp(this.collection,t);if(r.isFalsy(u))return e.renderer.renderTemplates(this.elseTemplates,t);var a=u.length,c=n.offset||0,l=void 0===n.limit?u.length:n.limit;u=u.slice(c,c+l),this.reversed&&u.reverse();var f=u.map(function(e,t){var r={};return r[o.variable]=e,r.forloop={first:0===t,index:t+1,index0:t,last:t===a-1,length:a,rindex:a-t,rindex0:a-t-1,stop:!1,skip:!1},r}),p="";return s(f,function(r){return t.push(r),e.renderer.renderTemplates(o.templates,t).then(function(e){return p+=e})["catch"](function(e){if(!(e instanceof i&&(p+=e.resolvedHTML,"continue"===e.message)))throw e}).then(function(){return t.pop()})})["catch"](function(e){if(!(e instanceof i&&"break"===e.message))throw e}).then(function(){return p})}})}},{"..":2,"../src/util/assert.js":16,"../src/util/promise.js":19,"any-promise":3}],29:[function(e,t){"use strict";var r=e("..");t.exports=function(e){e.registerTag("if",{parse:function(t,r){var n=this;this.branches=[],this.elseTemplates=[];var s,i=e.parser.parseStream(r).on("start",function(){return n.branches.push({cond:t.args,templates:s=[]})}).on("tag:elsif",function(e){n.branches[e.args]||n.branches.push({cond:e.args,templates:s=[]})}).on("tag:else",function(){return s=n.elseTemplates}).on("tag:endif",function(){return i.stop()}).on("template",function(e){return s.push(e)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});i.start()},render:function(t){for(var n=0;n<this.branches.length;n++){var s=this.branches[n],i=r.evalExp(s.cond,t);if(r.isTruthy(i))return e.renderer.renderTemplates(s.templates,t)}return e.renderer.renderTemplates(this.elseTemplates,t)}})}},{"..":2}],30:[function(e,t){"use strict";var r=e(".."),n=r.lexical,s=new RegExp("with\\s+("+n.value.source+")"),i=e("../src/util/assert.js");t.exports=function(e){e.registerTag("include",{parse:function(e){var t=n.value.exec(e.args);i(t,"illegal token "+e.raw),this.value=t[0],t=s.exec(e.args),t&&(this["with"]=t[1])},render:function(t,n,s){console.log("include",s.root);var i=r.evalValue(this.value,t);return this["with"]&&(n[i]=r.evalValue(this["with"],t)),e.getTemplate(i,s.root).then(function(r){return t.push(n),e.renderer.renderTemplates(r,t)}).then(function(e){return t.pop(),e})}})}},{"..":2,"../src/util/assert.js":16}],31:[function(e,t){"use strict";var r=e(".."),n=e("../src/util/assert.js"),s=r.lexical;t.exports=function(e){e.registerTag("increment",{parse:function(e){var t=e.args.match(s.identifier);n(t,"illegal identifier "+e.args),this.variable=t[0]},render:function(e){var t=e.get(this.variable);"number"!=typeof t&&(t=0),e.set(this.variable,t+1)}})}},{"..":2,"../src/util/assert.js":16}],32:[function(e,t){"use strict";t.exports=function(t){e("./assign.js")(t),e("./capture.js")(t),e("./case.js")(t),e("./comment.js")(t),e("./cycle.js")(t),e("./decrement.js")(t),e("./for.js")(t),e("./if.js")(t),e("./include.js")(t),e("./increment.js")(t),e("./layout.js")(t),e("./raw.js")(t),e("./tablerow.js")(t),e("./unless.js")(t)}},{"./assign.js":22,"./capture.js":23,"./case.js":24,"./comment.js":25,"./cycle.js":26,"./decrement.js":27,"./for.js":28,"./if.js":29,"./include.js":30,"./increment.js":31,"./layout.js":33,"./raw.js":34,"./tablerow.js":35,"./unless.js":36}],33:[function(e,t){"use strict";var r=e(".."),n=e("any-promise"),s=r.lexical,i=e("../src/util/assert.js");t.exports=function(e){e.registerTag("layout",{parse:function(t,r){var n=s.value.exec(t.args);i(n,"illegal token "+t.raw),this.layout=n[0],this.tpls=e.parser.parse(r)},render:function(t){var n=r.evalValue(this.layout,t),s="";return t.push({}),e.renderer.renderTemplates(this.tpls,t).then(function(t){return s+=t,e.getTemplate(n)}).then(function(r){return e.renderer.renderTemplates(r,t)}).then(function(e){return t.pop(),e})}}),e.registerTag("block",{parse:function(t,r){var n=this,s=/\w+/.exec(t.args);this.block=s?s[0]:"anonymous",this.tpls=[];var i=e.parser.parseStream(r).on("tag:endblock",function(){return i.stop()}).on("template",function(e){return n.tpls.push(e)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});i.start()},render:function(t){var r=this,s=t.get("_liquid.blocks."+this.block),i=n.resolve("");return void 0===s?i=e.renderer.renderTemplates(this.tpls,t).then(function(e){return t.set("_liquid.blocks."+r.block,e),e}):(t.set("_liquid.blocks."+this.block,s),i=n.resolve(s)),i}})}},{"..":2,"../src/util/assert.js":16,"any-promise":3}],34:[function(e,t){"use strict";var r=e("any-promise");t.exports=function(e){e.registerTag("raw",{parse:function(t,r){var n=this;this.tokens=[];var s=e.parser.parseStream(r);s.on("token",function(e){"endraw"===e.name?s.stop():n.tokens.push(e)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")}),s.start()},render:function(){ | ||
var e=this.tokens.map(function(e){return e.raw}).join("");return r.resolve(e)}})}},{"any-promise":3}],35:[function(e,t){"use strict";var r=e(".."),n=e("any-promise"),s=r.lexical,i=e("../src/util/assert.js"),o=new RegExp("^("+s.identifier.source+")\\s+in\\s+"+("("+s.value.source+")")+("(?:\\s+"+s.hash.source+")*$"));t.exports=function(e){e.registerTag("tablerow",{parse:function(t,r){var n=this,s=o.exec(t.args);i(s,"illegal tag: "+t.raw),this.variable=s[1],this.collection=s[2],this.templates=[];var u,a=e.parser.parseStream(r).on("start",function(){return u=n.templates}).on("tag:endtablerow",function(){return a.stop()}).on("template",function(e){return u.push(e)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});a.start()},render:function(t,s){var i,o,u=this,a=r.evalExp(this.collection,t)||[],c="<table>",l=s.offset||0,f=void 0===s.limit?a.length:s.limit,p=s.cols;if(!p)throw new Error("illegal cols: "+p);a=a.slice(l,l+f);var h=[];a.some(function(e){var t={};t[u.variable]=e,h.push(t)});var g=h.reduce(function(r,n,s){return r.then(function(){return i=Math.floor(s/p)+1,o=s%p+1,1===o&&(1!==i&&(c+="</tr>"),c+='<tr class="row'+i+'">'),c+='<td class="col'+o+'">'}).then(function(){return t.push(n),e.renderer.renderTemplates(u.templates,t)}).then(function(e){return t.pop(n),c+=e,c+="</td>"})},n.resolve(""));return g.then(function(){return i>0&&(c+="</tr>"),c+="</table>"})["catch"](function(e){throw e})}})}},{"..":2,"../src/util/assert.js":16,"any-promise":3}],36:[function(e,t){"use strict";var r=e("..");t.exports=function(e){e.registerTag("unless",{parse:function(t,r){var n=this;this.templates=[],this.elseTemplates=[];var s,i=e.parser.parseStream(r).on("start",function(){s=n.templates,n.cond=t.args}).on("tag:else",function(){return s=n.elseTemplates}).on("tag:endunless",function(){return i.stop()}).on("template",function(e){return s.push(e)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});i.start()},render:function(t){var n=r.evalExp(this.cond,t);return r.isFalsy(n)?e.renderer.renderTemplates(this.templates,t):e.renderer.renderTemplates(this.elseTemplates,t)}})}},{"..":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{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Liquid=e()}}(function(){return function e(t,r,n){function s(o,u){if(!r[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[o]={exports:{}};t[o][0].call(l.exports,function(e){var r=t[o][1][e];return s(r?r:e)},l,l.exports,e,t,r,n)}return r[o].exports}for(var i="function"==typeof require&&require,o=0;o<n.length;o++)s(n[o]);return s}({1:[function(e,t){"use strict";function r(e){return o(e).replace(/&|<|>|"|'/g,function(e){return f[e]})}function n(e){return o(e).replace(/&(amp|lt|gt|#34|#39);/g,function(e){return p[e]})}function s(e){var t=(e+"").split(".");return t.length>1?t[1].length:0}function i(e,t){return Math.max(s(e),s(t))}function o(e){return e=e||"",e+""}function u(e){return function(t,r){var n=i(t,r);return e(t,r).toFixed(n)}}function a(e){return l.forOwn(h,function(t,r){return e.registerFilter(r,t)})}var c=e("./src/util/strftime.js"),l=e("./src/util/underscore.js"),f={"&":"&","<":"<",">":">",'"':""","'":"'"},p={"&":"&","<":"<",">":">",""":'"',"'":"'"},h={abs:function(e){return Math.abs(e)},append:function(e,t){return e+t},capitalize:function(e){return o(e).charAt(0).toUpperCase()+e.slice(1)},ceil:function(e){return Math.ceil(e)},date:function(e,t){return"now"===e&&(e=new Date),c(e,t)},"default":function(e,t){return t||e},divided_by:function(e,t){return Math.floor(e/t)},downcase:function(e){return e.toLowerCase()},escape:r,escape_once:function(e){return r(n(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 e[e.length-1]},lstrip:function(e){return o(e).replace(/^\s+/,"")},map:function(e,t){return e.map(function(e){return e[t]})},minus:u(function(e,t){return e-t}),modulo:u(function(e,t){return e%t}),newline_to_br:function(e){return e.replace(/\n/g,"<br />")},plus:u(function(e,t){return e+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 o(e).split(t).join(r)},replace_first:function(e,t,r){return o(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 o(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 o(e).split(t)},strip:function(e){return o(e).trim()},strip_html:function(e){return o(e).replace(/<\/?\s*\w+\s*\/?>/g,"")},strip_newlines:function(e){return o(e).replace(/\n/g,"")},times:function(e,t){return e*t},truncate:function(e,t,r){return e=o(e),r=void 0===r?"...":r,t=t||16,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)?!1:(t[e]=!0,!0)})},upcase:function(e){return o(e).toUpperCase()},url_encode:encodeURIComponent};a.filters=h,t.exports=a},{"./src/util/strftime.js":20,"./src/util/underscore.js":21}],2:[function(e,t){"use strict";function r(e){e=i.assign({},e),e.root=n(e.root),e.root.length||(e.root=["."]),e.extname=e.extname||".liquid";var t=Object.create(b);return t.init(h(),g(),e),t}function n(e){return i.isArray(e)?e:i.isString(e)?[e]:[]}var s=e("./src/scope"),i=e("./src/util/underscore.js"),o=e("./src/util/assert.js"),u=e("./src/tokenizer.js"),a=e("./src/util/fs.js").statFileAsync,c=e("./src/util/fs.js").readFileAsync,l=e("path"),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"),x=e("any-promise"),w=e("./src/util/promise.js").anySeries,j=e("./src/util/error.js"),b={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){var t=u.parse(e);return this.parser.parse(t)},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 x.resolve().then(function(){return n.parse(e)}).then(function(e){return n.render(e,t,r)})["catch"](function(e){if(e instanceof j.RenderBreak)return e.html;throw e})},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)})["catch"](function(t){throw t.file=e,t})},evalOutput:function(e,t){var r=this.parser.parseOutput(e.trim());return this.renderer.evalOutput(r,t)},registerFilter:function(e,t){return this.filter.register(e,t)},registerTag:function(e,t){return this.tag.register(e,t)},lookup:function(e,t){t=this.options.root.concat(t||[]),t=i.uniq(t);var r=t.map(function(t){return l.resolve(t,e)});return w(r,function(e){return a(e).then(function(){return e})})["catch"](function(r){throw"ENOENT"===r.code&&(r.message="Failed to lookup "+e+" in: "+t),r})},getTemplate:function(e,t){var r=this;return l.extname(e)||(e+=this.options.extname),this.lookup(e,t).then(function(e){if(r.options.cache){var t=r.cache[e];return t?x.resolve(t):c(e).then(function(e){return r.parse(e)}).then(function(t){return r.cache[e]=t})}return c(e).then(function(e){return r.parse(e)})})},express:function(e){e=e||{};var t=this;return function(r,n,s){o(i.isArray(this.root)||i.isString(this.root),"illegal views root, are you using express.js?"),e.root=this.root,t.renderFile(r,n,e).then(function(e){return s(null,e)})["catch"](function(e){return s(e)})}}};r.lexical=p,r.isTruthy=v.isTruthy,r.isFalsy=v.isFalsy,r.evalExp=v.evalExp,r.evalValue=v.evalValue,r.Types={ParseError:j.ParseError,TokenizationEroor:j.TokenizationError,RenderBreak:j.RenderBreak,AssertionError:j.AssertionError},t.exports=r},{"./filters":1,"./src/filter.js":7,"./src/lexical.js":8,"./src/parser":10,"./src/render.js":11,"./src/scope":12,"./src/syntax.js":13,"./src/tag.js":14,"./src/tokenizer.js":15,"./src/util/assert.js":16,"./src/util/error.js":17,"./src/util/fs.js":18,"./src/util/promise.js":19,"./src/util/underscore.js":21,"./tags":32,"any-promise":3,path:6}],3:[function(e,t){"use strict";t.exports=e("./register")().Promise},{"./register":5}],4:[function(e,t){"use strict";var r="@@any-promise/REGISTRATION",n=null;t.exports=function(e,t){return function(s,i){s=s||null,i=i||{};var o=i.global!==!1;if(null===n&&o&&(n=e[r]||null),null!==n&&null!==s&&n.implementation!==s)throw new Error('any-promise already defined as "'+n.implementation+'". You can only register an implementation before the first call to require("any-promise") and an implementation cannot be changed');return null===n&&(n=null!==s&&"undefined"!=typeof i.Promise?{Promise:i.Promise,implementation:s}:t(s),o&&(e[r]=n)),n}}},{}],5:[function(e,t){"use strict";function r(){if("undefined"==typeof window.Promise)throw new Error("any-promise browser requires a polyfill or explicit registration e.g: require('any-promise/register/bluebird')");return{Promise:window.Promise,implementation:"window.Promise"}}t.exports=e("./loader")(window,r)},{"./loader":4}],6:[function(){"use strict"},{}],7:[function(e,t){"use strict";var r=e("./lexical.js"),n=e("./syntax.js"),s=e("./util/assert.js"),i=new RegExp(""+r.value.source,"g");t.exports=function(){function e(e){var t=Object.create(a);return t.parse(e)}function t(e,t){u[e]=t}function o(){u={}}var u={},a={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=r.filterLine.exec(e);s(t,"illegal filter: "+e);var n=t[1],o=t[2]||"",a=u[n];if("function"!=typeof a)return{name:n,error:new TypeError("undefined filter: "+n)};for(var c=[];t=i.exec(o.trim());)c.push(t[0]);return this.name=n,this.filter=a,this.args=c,this}};return{construct:e,register:t,clear:o}}},{"./lexical.js":8,"./syntax.js":13,"./util/assert.js":16}],8:[function(e,t){"use strict";function r(e){return A.test(e)}function n(e){return S.test(e)}function s(e){return P.test(e)}function i(e){return O.test(e)}function o(e){return b.exec(e)}function u(e){var t;return(t=e.match(R))?Number(e):(t=e.match(M))?"true"===e.toLowerCase():(t=e.match(q))?e.slice(1,-1):void 0}var a=/'[^']*'/,c=/"[^"]*"/,l=new RegExp(a.source+"|"+c.source),f=new RegExp("(?:"+l.source+"|[^'\"])*"),p=/-?\d+/,h=/-?\d+\.?\d*|\.?\d+/,g=/true|false/,d=/[\w-]+/,v=new RegExp("\\[(?:"+l.source+"|[\\w-\\.]+)\\]"),m=new RegExp("(?:"+l.source+"|"+g.source+"|"+h.source+")"),y=new RegExp(d.source+"(?:\\."+d.source+"|"+v.source+")*"),x=new RegExp("(?:"+y.source+"|"+h.source+")"),w=new RegExp("\\("+x.source+"\\.\\."+x.source+"\\)"),j=new RegExp("\\(("+x.source+")\\.\\.("+x.source+")\\)"),b=new RegExp("(?:"+y.source+"|"+m.source+"|"+w.source+")"),E=new RegExp("(?:"+d.source+")\\s*:\\s*(?:"+b.source+")"),T=new RegExp("("+d.source+")\\s*:\\s*("+b.source+")","g"),k=new RegExp("^\\s*("+d.source+")\\s*(.*)\\s*$"),S=new RegExp("^"+m.source+"$","i"),O=new RegExp("^"+y.source+"$"),R=new RegExp("^"+h.source+"$"),M=new RegExp("^"+g.source+"$","i"),q=new RegExp("^"+l.source+"$"),P=new RegExp("^"+j.source+"$"),A=new RegExp("^"+p.source+"$"),L=new RegExp(b.source+"(\\s*,\\s*"+b.source+")*"),F=new RegExp(d.source+"(?:\\s*:\\s*"+L.source+")?","g"),D=new RegExp("("+d.source+")(?:\\s*:\\s*("+L.source+"))?"),I=new RegExp("^"+D.source+"$"),_=[/\s+or\s+/,/\s+and\s+/,/==|!=|<=|>=|<|>|\s+contains\s+/];t.exports={quoted:l,number:h,bool:g,literal:m,filter:F,integer:p,hash:E,hashCapture:T,range:w,rangeCapture:j,identifier:d,value:b,quoteBalanced:f,operators:_,quotedLine:q,numberLine:R,boolLine:M,rangeLine:P,literalLine:S,filterLine:I,tagLine:k,isLiteral:n,isVariable:i,parseLiteral:u,isRange:s,matchValue:o,isInteger:r}},{}],9:[function(e,t){"use strict";var r={"==":function(e,t){return e==t},"!=":function(e,t){return e!=t},">":function(e,t){return e>t},"<":function(e,t){return t>e},">=":function(e,t){return e>=t},"<=":function(e,t){return t>=e},contains:function(e,t){return e.indexOf(t)>-1},and:function(e,t){return e&&t},or:function(e,t){return e||t}};t.exports=r},{}],10:[function(e,t){"use strict";var r=e("./lexical.js"),n=e("./util/error.js").ParseError,s=e("./util/assert.js");t.exports=function(e,t){function i(e){for(var t,r=[];t=e.shift();)r.push(o(t,e));return r}function o(e,t){try{switch(e.type){case"tag":return u(e,t);case"output":return a(e.value);case"html":return e}}catch(r){throw new n(r.message,e.input,e.line,r)}}function u(t,r){return"continue"===t.name||"break"===t.name?t:e.construct(t,r)}function a(e){var n=r.matchValue(e);s(n,"illegal output string: "+e);var i=n[0];e=e.substr(n.index+n[0].length);for(var o=[];n=r.filter.exec(e);)o.push([n[0].trim()]);return{type:"output",initial:i,filters:o.map(function(e){return t.construct(e)})}}function c(e){var t=Object.create(l);return t.init(e)}var l={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];return"function"==typeof r?(r(t),!0):void 0},start:function(){this.trigger("start");for(var e;!this.stopRequested&&(e=this.tokens.shift());)if(!(this.trigger("token",e)||"tag"==e.type&&this.trigger("tag:"+e.name,e))){var t=o(e,this.tokens);this.trigger("template",t)}return this.stopRequested||this.trigger("end"),this},stop:function(){return this.stopRequested=!0,this}};return{parse:i,parseTag:u,parseStream:c,parseOutput:a}}},{"./lexical.js":8,"./util/assert.js":16,"./util/error.js":17}],11:[function(e,t){"use strict";function r(){var e=Object.create(c);return e}function n(e){return"string"==typeof e?e:JSON.stringify(e)}var s=e("./syntax.js"),i=e("any-promise"),o=e("./util/promise.js").mapSeries,u=e("./util/error.js").RenderBreak,a=e("./util/assert.js"),c=(e("./util/underscore.js"),{renderTemplates:function(e,t){function r(e){return"tag"===e.type?this.renderTag(e,t).then(function(e){return void 0===e?"":e}):"output"===e.type?i.resolve(this.evalOutput(e,t)).then(function(e){return void 0===e?"":n(e)}):i.resolve(e.value)}var s=this;a(t,"unable to evalTemplates: scope undefined");var c="";return o(e,function(e){return r.call(s,e).then(function(e){return c+=e})["catch"](function(e){throw e instanceof u&&(e.resolvedHTML=c),e})}).then(function(){return c})},renderTag:function(e,t){return"continue"===e.name?i.reject(new u("continue")):"break"===e.name?i.reject(new u("break")):e.render(t)},evalOutput:function(e,t){a(t,"unable to evalOutput: scope undefined");var r=s.evalExp(e.initial,t);return e.filters.some(function(e){if(e.error){if(t.get("liquid.strict_filters"))throw e.error;return r="",!0}r=e.render(r,t)}),r}});t.exports=r},{"./syntax.js":13,"./util/assert.js":16,"./util/error.js":17,"./util/promise.js":19,"./util/underscore.js":21,"any-promise":3}],12:[function(e,t,r){"use strict";function n(e,t){for(var r=1,n=t;n<e.length;n++)if("["===e[n]&&r++,"]"===e[n]&&(r--,0===r))return n;return-1}var s=e("./util/underscore.js"),i=e("./lexical.js"),o=e("./util/assert.js"),u=/undefined variable|Cannot read property .* of undefined/,a={getAll:function(){for(var e={},t=this.scopes.length-1;t>=0;t--)s.assign(e,this.scopes[t]);return e},get:function(e){for(var t=this.scopes.length-1;t>=0;t--)try{return this.getPropertyByPath(this.scopes[t],e)}catch(r){if(!u.test(r.message)||this.opts.strict_variables)throw r.message+=": "+e,r}if(this.opts.strict_variables)throw new TypeError("undefined variable: "+e)},set:function(e,t){return this.setPropertyByPath(this.scopes[this.scopes.length-1],e,t),this},push:function(e){return o(e,"trying to push "+e+" into scopes"),this.scopes.push(e)},pop:function(){return this.scopes.pop()},unshift:function(e){return o(e,"trying to push "+e+" into scopes"),this.scopes.unshift(e)},shift:function(){return this.scopes.shift()},setPropertyByPath:function(e,t,r){if(s.isString(t))for(var n=t.replace(/\[/g,".").replace(/\]/g,"").split("."),i=0;i<n.length;i++){var o=n[i];if(i===n.length-1)return e[o]=r;void 0===e[o]&&(e[o]={}),e=e[o]||{}}},getPropertyByPath:function(e,t){var r=this.propertyAccessSeq(t+""),n=r.shift();if(!e.hasOwnProperty(n))throw new TypeError("undefined variable");var s=e[n];return r.forEach(function(e){return s=s[e]}),s},propertyAccessSeq:function(e){for(var t=[],r="",s=0;s<e.length;s++)if("["===e[s]){t.push(r),r="";var u=e[s+1];if("'"!==u&&'"'!==u){var a=n(e,s+1);o(-1!==a,"unbalanced []: "+e),r=e.slice(s+1,a),t.push(i.isInteger(r)?r:this.get(r)),r="",s=a}else a=e.indexOf(u,s+2),o(-1!==a,"unbalanced "+u+": "+e),r=e.slice(s+2,a),t.push(r),r="",s=a+1}else"."===e[s]?(t.push(r),r=""):r+=e[s];return r.length&&t.push(r),t}};r.factory=function(e,t){t=s.assign({strict_variables:!1,strict_filters:!1,blocks:{},root:[]},t),e=s.assign(e,{liquid:t});var r=Object.create(a);return r.opts=t,r.scopes=[e],r}},{"./lexical.js":8,"./util/assert.js":16,"./util/underscore.js":21}],13:[function(e,t){"use strict";function r(e,t){a(t,"unable to evalExp: scope undefined");for(var s,i=u.operators,c=0;c<i.length;c++){var l=i[c],f=new RegExp("^("+u.quoteBalanced.source+")("+l.source+")("+u.quoteBalanced.source+")$");if(s=e.match(f)){var p=r(s[1],t),h=o[s[2].trim()],g=r(s[3],t);return h(p,g)}}if(s=e.match(u.rangeLine)){for(var d=n(s[1],t),v=n(s[2],t),m=[],y=d;v>=y;y++)m.push(y);return m}return n(e,t)}function n(e,t){return e=e&&e.trim(),e?u.isLiteral(e)?u.parseLiteral(e):u.isVariable(e)?t.get(e):void 0:void 0}function s(e){return e instanceof Array?!!e.length:!!e}function i(e){return!s(e)}var o=e("./operators.js"),u=e("./lexical.js"),a=e("../src/util/assert.js");t.exports={evalExp:r,evalValue:n,isTruthy:s,isFalsy:i}},{"../src/util/assert.js":16,"./lexical.js":8,"./operators.js":9}],14:[function(e,t){"use strict";function r(e,t){var r,s={};for(n.hashCapture.lastIndex=0;r=n.hashCapture.exec(e);){var o=r[1],u=r[2];s[o]=i.evalValue(u,t)}return s}var n=e("./lexical.js"),s=e("any-promise"),i=e("./syntax.js"),o=e("./util/assert.js");t.exports=function(){function e(e,t){i[e]=t}function t(e,t){var r=Object.create(u);return r.parse(e,t),r}function n(){i={}}var i={},u={render:function(e){var t=r(this.token.args,e);return this.tagImpl.render&&this.tagImpl.render(e,t)||s.resolve("")},parse:function(e,t){this.type="tag",this.token=e,this.name=e.name;var r=i[this.name];o(r,"tag "+this.name+" not found"),this.tagImpl=Object.create(r),this.tagImpl.parse&&this.tagImpl.parse(e,t)}};return{construct:t,register:e,clear:n}}},{"./lexical.js":8,"./syntax.js":13,"./util/assert.js":16,"any-promise":3}],15:[function(e,t,r){"use strict";function n(e){function t(e,t,s){return{type:e,raw:s[t],value:s[t+1].trim(),line:n(s),input:r(s)}}function r(e){var t=e.input.lastIndexOf("\n",e.index),r=e.input.indexOf("\n",e.index);return-1===r&&(r=e.input.length),e.input.slice(t+1,r)}function n(e){var t=e.input.slice(g+1,e.index).split("\n");return d+=t.length-1,g=e.index,d+1}var a=[];u(o.isString(e),new i("illegal input type"));for(var c,l,f,p=/({%(.*?)%})|({{(.*?)}})/g,h=0,g=-1,d=0;null!==(c=p.exec(e));){if(c.index>h&&(l=e.slice(h,c.index),a.push({type:"html",raw:l,value:l})),c[1]){f=t("tag",1,c);var v=f.value.match(s.tagLine);if(!v)throw new i("illegal tag: "+f.raw,f.input,f.line);f.name=v[1],f.args=v[2],a.push(f)}else f=t("output",3,c),a.push(f);h=p.lastIndex}return e.length>h&&(l=e.slice(h,e.length),a.push({type:"html",raw:l,value:l})),a}var s=e("./lexical.js"),i=e("./util/error.js").TokenizationError,o=e("./util/underscore.js"),u=e("../src/util/assert.js");r.parse=n},{"../src/util/assert.js":16,"./lexical.js":8,"./util/error.js":17,"./util/underscore.js":21}],16:[function(e,t){"use strict";function r(e,t){if(!e){if(t instanceof Error)throw t;var t=t||"expect "+e+" to be true";throw new n(t)}}var n=e("./error.js").AssertionError;t.exports=r},{"./error.js":17}],17:[function(e,t){"use strict";function r(e,t,r){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.message=e,this.input=t,this.line=r}function n(e,t,r,n){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.originalError=n,this.message=e,this.input=t,this.line=r}function s(e){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.message=e}function i(e){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.message=e}r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,s.prototype=Object.create(Error.prototype),s.prototype.constructor=s,i.prototype=Object.create(Error.prototype),i.prototype.constructor=i,t.exports={TokenizationError:r,ParseError:n,RenderBreak:s,AssertionError:i}},{}],18:[function(e,t){"use strict";function r(e){return new Promise(function(t,r){s.readFile(e,"utf8",function(e,n){e?r(e):t(n)})})}function n(e){return new Promise(function(t,r){s.stat(e,function(e,n){return e?r(e):t(n)})})}var s=e("fs");t.exports={readFileAsync:r,statFileAsync:n}},{fs:6}],19:[function(e,t,r){"use strict";function n(e,t){var r=i.reject(new Error("init"));return e.forEach(function(n,s){r=r["catch"](function(){return t(n,s,e)})}),r}function s(e,t){var r=i.resolve("init"),n=[];return e.forEach(function(s,i){r=r.then(function(){return t(s,i,e)}).then(function(e){return n.push(e)})}),r.then(function(){return n})}var i=e("any-promise");r.anySeries=n,r.mapSeries=s},{"any-promise":3}],20:[function(e,t){"use strict";var r=["January","February","March","April","May","June","July","August","September","October","November","December"],n=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],s=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],i=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],o={1:"st",2:"nd",3:"rd","default":"th"},u={daysInMonth:function(e){var t=u.isLeapYear(e)?29:28;return[31,t,31,30,31,30,31,31,30,31,30,31]},getDayOfYear:function(e){for(var t=0,r=0;r<e.getMonth();++r)t+=u.daysInMonth(e)[r];return t+e.getDate()},getWeekOfYear:function(e,t){var r=this.getDayOfYear(e)+(t-e.getDay()),n=new Date(e.getFullYear(),0,1),s=7-n.getDay()+t;return a.pad(Math.floor((r-s)/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 o[r]||o["default"]},century:function(e){return parseInt(e.getFullYear().toString().substring(0,2),10)}},a={pad:function f(e,t,r){r||(r="0");for(var n=e.toString(),f=t-n.length;f-->0;)n=r+n;return n}},c={a:function(e){return i[e.getDay()]},A:function(e){return s[e.getDay()]},b:function(e){return n[e.getMonth()]},B:function(e){return r[e.getMonth()]},c:function(e){return e.toLocaleString()},C:function(e){return u.century(e)},d:function(e){return a.pad(e.getDate(),2)},e:function(e){return a.pad(e.getDate(),2," ")},H:function(e){return a.pad(e.getHours(),2)},I:function(e){return a.pad(e.getHours()%12||12,2)},j:function(e){return a.pad(u.getDayOfYear(e),3)},k:function(e){return a.pad(e.getHours(),2," ")},l:function(e){return a.pad(e.getHours()%12||12,2," ")},L:function(e){return a.pad(e.getMilliseconds(),3)},m:function(e){return a.pad(e.getMonth()+1,2)},M:function(e){return a.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 u.getSuffix(e)},s:function(e){return Math.round(e.valueOf()/1e3)},S:function(e){return a.pad(e.getSeconds(),2)},u:function(e){return e.getDay()||7},U:function(e){return u.getWeekOfYear(e,0)},w:function(e){return e.getDay()},W:function(e){return u.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(t>0?"-":"+")+a.pad(Math.abs(t),4)},"%":function(){return"%"}};c.h=c.b,c.N=c.L;var l=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=c[o];r+=u?u.call(this,e):"%"+o}};t.exports=l},{}],21:[function(e,t,r){"use strict";function n(e){return e instanceof String||"string"==typeof e}function s(e,t){e=e||{};for(var r in e)if(e.hasOwnProperty(r)&&t(e[r],r,e)===!1)break;return e}function i(e){e=l(e)?e:{};var t=Array.prototype.slice.call(arguments,1);return t.forEach(function(t){o(e,t)}),e}function o(e,t){return e?(s(t,function(t,r){e[r]=t}),e):e}function u(e){return e instanceof Array}function a(e){return function(t){return console.log("["+e+"]",t),t}}function c(e){for(var t={},r=[],n=0,s=e.length;s>n;++n)t.hasOwnProperty(e[n])||(r.push(e[n]),t[e[n]]=1);return r}function l(e){return null!==e&&"object"===("undefined"==typeof e?"undefined":f(e))}var f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};r.isString=n,r.isArray=u,r.isObject=l,r.forOwn=s,r.assign=i,r.uniq=c,r.echo=a},{}],22:[function(e,t){"use strict";var r=e(".."),n=r.lexical,s=e("any-promise"),i=new RegExp("("+n.identifier.source+")\\s*=(.*)"),o=e("../src/util/assert.js");t.exports=function(e){e.registerTag("assign",{parse:function(e){var t=e.args.match(i);o(t,"illegal token "+e.raw),this.key=t[1],this.value=t[2]},render:function(t){return t.set(this.key,e.evalOutput(this.value,t)),s.resolve("")}})}},{"..":2,"../src/util/assert.js":16,"any-promise":3}],23:[function(e,t){"use strict";var r=e(".."),n=r.lexical,s=new RegExp("("+n.identifier.source+")"),i=e("../src/util/assert.js");t.exports=function(e){e.registerTag("capture",{parse:function(t,r){var n=this,o=t.args.match(s);i(o,t.args+" not valid identifier"),this.variable=o[1],this.templates=[];var u=e.parser.parseStream(r);u.on("tag:endcapture",function(){return u.stop()}).on("template",function(e){return n.templates.push(e)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")}),u.start()},render:function(t){var r=this;return e.renderer.renderTemplates(this.templates,t).then(function(e){t.set(r.variable,e)})}})}},{"..":2,"../src/util/assert.js":16}],24:[function(e,t){"use strict";{var r=e("..");e("../src/util/assert.js")}t.exports=function(e){e.registerTag("case",{parse:function(t,r){var n=this;this.cond=t.args,this.cases=[],this.elseTemplates=[];var s=[],i=e.parser.parseStream(r).on("tag:when",function(e){n.cases[e.args]||n.cases.push({val:e.args,templates:s=[]})}).on("tag:else",function(){return s=n.elseTemplates}).on("tag:endcase",function(){return i.stop()}).on("template",function(e){return s.push(e)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});i.start()},render:function(t){for(var n=0;n<this.cases.length;n++){var s=this.cases[n],i=r.evalExp(s.val,t),o=r.evalExp(this.cond,t);if(i===o)return e.renderer.renderTemplates(s.templates,t)}return e.renderer.renderTemplates(this.elseTemplates,t)}})}},{"..":2,"../src/util/assert.js":16}],25:[function(e,t){"use strict";t.exports=function(e){e.registerTag("comment",{parse:function(t,r){var n=e.parser.parseStream(r);n.on("token",function(e){"endcomment"===e.name&&n.stop()}).on("end",function(){throw new Error("tag "+t.raw+" not closed")}),n.start()}})}},{}],26:[function(e,t){"use strict";var r=e(".."),n=e("any-promise"),s=r.lexical,i=new RegExp("^(?:("+s.value.source+")\\s*:\\s*)?(.*)$"),o=new RegExp(s.value.source,"g"),u=e("../src/util/assert.js");t.exports=function(e){e.registerTag("cycle",{parse:function(e){var t=i.exec(e.args);u(t,"illegal tag: "+e.raw),this.group=t[1]||"";var r=t[2];for(this.candidates=[];t=o.exec(r);)this.candidates.push(t[0]);u(this.candidates.length,"empty candidates: "+e.raw)},render:function(e){var t=r.evalValue(this.group,e),s="cycle:"+t+":"+this.candidates.join(","),i=e.get("liquid"),o=i[s];void 0===o&&(o=i[s]=0);var u=this.candidates[o];return o=(o+1)%this.candidates.length,i[s]=o,n.resolve(r.evalValue(u,e))}})}},{"..":2,"../src/util/assert.js":16,"any-promise":3}],27:[function(e,t){"use strict";var r=e(".."),n=r.lexical,s=e("../src/util/assert.js");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){var t=e.get(this.variable);"number"!=typeof t&&(t=0),e.set(this.variable,t-1)}})}},{"..":2,"../src/util/assert.js":16}],28:[function(e,t){"use strict";var r=e(".."),n=(e("any-promise"),r.lexical),s=e("../src/util/promise.js").mapSeries,i=r.Types.RenderBreak,o=e("../src/util/assert.js"),u=new RegExp("^("+n.identifier.source+")\\s+in\\s+"+("("+n.value.source+")")+("(?:\\s+"+n.hash.source+")*")+"(?:\\s+(reversed))?$");t.exports=function(e){e.registerTag("for",{parse:function(t,r){var n=this,s=u.exec(t.args);o(s,"illegal tag: "+t.raw),this.variable=s[1],this.collection=s[2],this.reversed=!!s[3],this.templates=[],this.elseTemplates=[];var i,a=e.parser.parseStream(r).on("start",function(){return i=n.templates}).on("tag:else",function(){return i=n.elseTemplates}).on("tag:endfor",function(){return a.stop()}).on("template",function(e){return i.push(e)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});a.start()},render:function(t,n){var o=this,u=r.evalExp(this.collection,t);if(r.isFalsy(u))return e.renderer.renderTemplates(this.elseTemplates,t);var a=u.length,c=n.offset||0,l=void 0===n.limit?u.length:n.limit;u=u.slice(c,c+l),this.reversed&&u.reverse();var f=u.map(function(e,t){var r={};return r[o.variable]=e,r.forloop={first:0===t,index:t+1,index0:t,last:t===a-1,length:a,rindex:a-t,rindex0:a-t-1,stop:!1,skip:!1},r}),p="";return s(f,function(r){return t.push(r),e.renderer.renderTemplates(o.templates,t).then(function(e){return p+=e})["catch"](function(e){if(!(e instanceof i&&(p+=e.resolvedHTML,"continue"===e.message)))throw e}).then(function(){return t.pop()})})["catch"](function(e){if(!(e instanceof i&&"break"===e.message))throw e}).then(function(){return p})}})}},{"..":2,"../src/util/assert.js":16,"../src/util/promise.js":19,"any-promise":3}],29:[function(e,t){"use strict";var r=e("..");t.exports=function(e){e.registerTag("if",{parse:function(t,r){var n=this;this.branches=[],this.elseTemplates=[];var s,i=e.parser.parseStream(r).on("start",function(){return n.branches.push({cond:t.args,templates:s=[]})}).on("tag:elsif",function(e){n.branches[e.args]||n.branches.push({cond:e.args,templates:s=[]})}).on("tag:else",function(){return s=n.elseTemplates}).on("tag:endif",function(){return i.stop()}).on("template",function(e){return s.push(e)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});i.start()},render:function(t){for(var n=0;n<this.branches.length;n++){var s=this.branches[n],i=r.evalExp(s.cond,t);if(r.isTruthy(i))return e.renderer.renderTemplates(s.templates,t)}return e.renderer.renderTemplates(this.elseTemplates,t)}})}},{"..":2}],30:[function(e,t){"use strict";var r=e(".."),n=r.lexical,s=new RegExp("with\\s+("+n.value.source+")"),i=e("../src/util/assert.js");t.exports=function(e){e.registerTag("include",{parse:function(e){var t=n.value.exec(e.args);i(t,"illegal token "+e.raw),this.value=t[0],t=s.exec(e.args),t&&(this["with"]=t[1])},render:function(t,n){var s=r.evalValue(this.value,t),i=t.get("liquid"),o=i.blocks;return i.blocks={},this["with"]&&(n[s]=r.evalValue(this["with"],t)),e.getTemplate(s,i.root).then(function(r){return t.push(n),e.renderer.renderTemplates(r,t)}).then(function(e){return t.pop(),i.blocks=o,e})}})}},{"..":2,"../src/util/assert.js":16}],31:[function(e,t){"use strict";var r=e(".."),n=e("../src/util/assert.js"),s=r.lexical;t.exports=function(e){e.registerTag("increment",{parse:function(e){var t=e.args.match(s.identifier);n(t,"illegal identifier "+e.args),this.variable=t[0]},render:function(e){var t=e.get(this.variable);"number"!=typeof t&&(t=0),e.set(this.variable,t+1)}})}},{"..":2,"../src/util/assert.js":16}],32:[function(e,t){"use strict";t.exports=function(t){e("./assign.js")(t),e("./capture.js")(t),e("./case.js")(t),e("./comment.js")(t),e("./cycle.js")(t),e("./decrement.js")(t),e("./for.js")(t),e("./if.js")(t),e("./include.js")(t),e("./increment.js")(t),e("./layout.js")(t),e("./raw.js")(t),e("./tablerow.js")(t),e("./unless.js")(t)}},{"./assign.js":22,"./capture.js":23,"./case.js":24,"./comment.js":25,"./cycle.js":26,"./decrement.js":27,"./for.js":28,"./if.js":29,"./include.js":30,"./increment.js":31,"./layout.js":33,"./raw.js":34,"./tablerow.js":35,"./unless.js":36}],33:[function(e,t){"use strict";var r=e(".."),n=e("any-promise"),s=r.lexical,i=e("../src/util/assert.js");t.exports=function(e){e.registerTag("layout",{parse:function(t,r){var n=s.value.exec(t.args);i(n,"illegal token "+t.raw),this.layout=n[0],this.tpls=e.parser.parse(r)},render:function(t,n){var s=r.evalValue(this.layout,t),i=t.get("liquid");return e.renderer.renderTemplates(this.tpls,t).then(function(){return e.getTemplate(s,i.root)}).then(function(e){return t.push(n),e}).then(function(r){return e.renderer.renderTemplates(r,t)}).then(function(e){return t.pop(),e})}}),e.registerTag("block",{parse:function(t,r){var n=this,s=/\w+/.exec(t.args);this.block=s?s[0]:"anonymous",this.tpls=[];var i=e.parser.parseStream(r).on("tag:endblock",function(){return i.stop()}).on("template",function(e){return n.tpls.push(e)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});i.start()},render:function(t){var r=this,s=t.get("liquid"),i=s.blocks[this.block];return void 0===i?e.renderer.renderTemplates(this.tpls,t).then(function(e){ | ||
return s.blocks[r.block]=e,e}):(s.blocks[this.block]=i,n.resolve(i))}})}},{"..":2,"../src/util/assert.js":16,"any-promise":3}],34:[function(e,t){"use strict";var r=e("any-promise");t.exports=function(e){e.registerTag("raw",{parse:function(t,r){var n=this;this.tokens=[];var s=e.parser.parseStream(r);s.on("token",function(e){"endraw"===e.name?s.stop():n.tokens.push(e)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")}),s.start()},render:function(){var e=this.tokens.map(function(e){return e.raw}).join("");return r.resolve(e)}})}},{"any-promise":3}],35:[function(e,t){"use strict";var r=e(".."),n=e("any-promise"),s=r.lexical,i=e("../src/util/assert.js"),o=new RegExp("^("+s.identifier.source+")\\s+in\\s+"+("("+s.value.source+")")+("(?:\\s+"+s.hash.source+")*$"));t.exports=function(e){e.registerTag("tablerow",{parse:function(t,r){var n=this,s=o.exec(t.args);i(s,"illegal tag: "+t.raw),this.variable=s[1],this.collection=s[2],this.templates=[];var u,a=e.parser.parseStream(r).on("start",function(){return u=n.templates}).on("tag:endtablerow",function(){return a.stop()}).on("template",function(e){return u.push(e)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});a.start()},render:function(t,s){var i,o,u=this,a=r.evalExp(this.collection,t)||[],c="<table>",l=s.offset||0,f=void 0===s.limit?a.length:s.limit,p=s.cols;if(!p)throw new Error("illegal cols: "+p);a=a.slice(l,l+f);var h=[];a.some(function(e){var t={};t[u.variable]=e,h.push(t)});var g=h.reduce(function(r,n,s){return r.then(function(){return i=Math.floor(s/p)+1,o=s%p+1,1===o&&(1!==i&&(c+="</tr>"),c+='<tr class="row'+i+'">'),c+='<td class="col'+o+'">'}).then(function(){return t.push(n),e.renderer.renderTemplates(u.templates,t)}).then(function(e){return t.pop(n),c+=e,c+="</td>"})},n.resolve(""));return g.then(function(){return i>0&&(c+="</tr>"),c+="</table>"})["catch"](function(e){throw e})}})}},{"..":2,"../src/util/assert.js":16,"any-promise":3}],36:[function(e,t){"use strict";var r=e("..");t.exports=function(e){e.registerTag("unless",{parse:function(t,r){var n=this;this.templates=[],this.elseTemplates=[];var s,i=e.parser.parseStream(r).on("start",function(){s=n.templates,n.cond=t.args}).on("tag:else",function(){return s=n.elseTemplates}).on("tag:endunless",function(){return i.stop()}).on("template",function(e){return s.push(e)}).on("end",function(){throw new Error("tag "+t.raw+" not closed")});i.start()},render:function(t){var n=r.evalExp(this.cond,t);return r.isFalsy(n)?e.renderer.renderTemplates(this.templates,t):e.renderer.renderTemplates(this.elseTemplates,t)}})}},{"..":2}]},{},[2])(2)}); |
31
index.js
@@ -7,3 +7,3 @@ const Scope = require('./src/scope'); | ||
const readFileAsync = require('./src/util/fs.js').readFileAsync; | ||
const pathResolve = require('./src/util/fs.js').pathResolve; | ||
const path = require('path'); | ||
const Render = require('./src/render.js'); | ||
@@ -42,11 +42,4 @@ const lexical = require('./src/lexical.js'); | ||
render: function(tpl, ctx, opts) { | ||
opts = _.assign({ | ||
strict_variables: false, | ||
strict_filters: false, | ||
root: [] | ||
}, opts); | ||
this.renderer.initRegister(opts); | ||
var scope = Scope.factory(ctx, { | ||
strict: opts.strict_variables, | ||
}); | ||
opts = _.assign({}, this.options, opts); | ||
var scope = Scope.factory(ctx, opts); | ||
return this.renderer.renderTemplates(tpl, scope); | ||
@@ -86,3 +79,4 @@ }, | ||
root = this.options.root.concat(root || []); | ||
var paths = root.map(root => pathResolve(root, filepath)); | ||
root = _.uniq(root); | ||
var paths = root.map(root => path.resolve(root, filepath)); | ||
return anySeries(paths, path => statFileAsync(path).then(() => path)) | ||
@@ -97,3 +91,3 @@ .catch((e) => { | ||
getTemplate: function(filepath, root) { | ||
if (!filepath.match(/\.\w+$/)) { | ||
if(!path.extname(filepath)){ | ||
filepath += this.options.extname; | ||
@@ -117,9 +111,10 @@ } | ||
}, | ||
express: function(renderOption) { | ||
renderOption = renderOption || {}; | ||
express: function(opts) { | ||
opts = opts || {}; | ||
var self = this; | ||
return function(filePath, options, callback) { | ||
assert(_.isArray(this.root), 'illegal views root, are you using express.js?'); | ||
renderOption.root = this.root; | ||
self.renderFile(filePath, options, renderOption) | ||
return function(filePath, ctx, callback) { | ||
assert(_.isArray(this.root) || _.isString(this.root), | ||
'illegal views root, are you using express.js?'); | ||
opts.root = this.root; | ||
self.renderFile(filePath, ctx, opts) | ||
.then(html => callback(null, html)) | ||
@@ -126,0 +121,0 @@ .catch(e => callback(e)); |
{ | ||
"name": "shopify-liquid", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "Liquid template engine for JavaScript, Node.js and Browser", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -51,3 +51,5 @@ # shopify-liquid | ||
extname: '.liquid', | ||
cache: false | ||
cache: false, | ||
strict_filters: false, // default: false | ||
strict_variables: false // default: false | ||
}); | ||
@@ -67,3 +69,3 @@ engine.renderFile("hello.liquid", {name: 'alice'}) | ||
If an array, the files are looked up in the order they occur in the array. | ||
Defaults to `["."]` | ||
Defaults to `process.cwd()` | ||
@@ -74,23 +76,8 @@ * `extname` is used to lookup the template file when filepath doesn't include an extension name. Defaults to `.liquid` | ||
## Strict Rendering | ||
* `strict_filters` is used to enable strict filter existence. If set to `false`, undefined filters will be rendered as empty string. Otherwise, undefined filters will cause an exception. Defaults to `false`. | ||
Undefined filters and variables will be rendered as empty string by default. | ||
Enable strict rendering to throw errors upon undefined variables/filters: | ||
* `strict_variables` is used to enable strict variable derivation. | ||
If set to `false`, undefined variables will be rendered as empty string. | ||
Otherwise, undefined variables will cause an exception. Defaults to `false`. | ||
```javascript | ||
var opts = { | ||
strict_variables: true, | ||
strict_filters: true | ||
}; | ||
engine.parseAndRender("{{ foo }}", {}, opts).catch(function(err){ | ||
// err.message === undefined variable: foo | ||
}); | ||
engine.parseAndRender("{{ 'foo' | filter1 }}", {}, opts).catch(function(err){ | ||
// err.message === undefined filter: filter1 | ||
}); | ||
// Note: the below opts also work: | ||
// engine.render(tpl, ctx, opts) | ||
// engine.renderFile(path, ctx, opts) | ||
``` | ||
## Use with Express.js | ||
@@ -110,3 +97,4 @@ | ||
Note: includes and layouts lookup path should always be specified by `Liquid({root: []})`. | ||
When using with Express.js, partials(includes and layouts) will be looked up in | ||
both Liquid `root` and Express `views` directories. | ||
@@ -113,0 +101,0 @@ ## Use in Browser |
@@ -24,3 +24,3 @@ const lexical = require('./lexical.js'); | ||
name: name, | ||
error: new Error(`undefined filter: ${name}`) | ||
error: new TypeError(`undefined filter: ${name}`) | ||
}; | ||
@@ -27,0 +27,0 @@ } |
@@ -6,2 +6,3 @@ const Syntax = require('./syntax.js'); | ||
const assert = require('./util/assert.js'); | ||
const _ = require('./util/underscore.js'); | ||
@@ -45,3 +46,3 @@ var render = { | ||
} | ||
return template.render(scope, this.register); | ||
return template.render(scope); | ||
}, | ||
@@ -54,3 +55,3 @@ | ||
if (filter.error) { | ||
if (this.register.strict_filters) { | ||
if (scope.get('liquid.strict_filters')) { | ||
throw filter.error; | ||
@@ -65,6 +66,2 @@ } else { | ||
return val; | ||
}, | ||
initRegister: function(opts) { | ||
return this.register = opts; | ||
} | ||
@@ -75,3 +72,2 @@ }; | ||
var instance = Object.create(render); | ||
instance.register = {}; | ||
return instance; | ||
@@ -78,0 +74,0 @@ } |
const _ = require('./util/underscore.js'); | ||
const lexical = require('./lexical.js'); | ||
const assert = require('./util/assert.js'); | ||
const referenceError = /undefined variable|Cannot read property .* of undefined/; | ||
var Scope = { | ||
safeGet: function(str) { | ||
var i; | ||
// get all | ||
if (str === undefined) { | ||
var ctx = {}; | ||
for (i = this.scopes.length - 1; i >= 0; i--) { | ||
var scp = this.scopes[i]; | ||
for (var k in scp) { | ||
if (scp.hasOwnProperty(k)) { | ||
ctx[k] = scp[k]; | ||
} | ||
getAll: function() { | ||
var ctx = {}; | ||
for (var i = this.scopes.length - 1; i >= 0; i--) { | ||
_.assign(ctx, this.scopes[i]); | ||
} | ||
return ctx; | ||
}, | ||
get: function(str) { | ||
for (var i = this.scopes.length - 1; i >= 0; i--) { | ||
try { | ||
return this.getPropertyByPath(this.scopes[i], str); | ||
} catch (e) { | ||
if (!referenceError.test(e.message) || this.opts.strict_variables) { | ||
e.message += ': ' + str; | ||
throw e; | ||
} | ||
} | ||
return ctx; | ||
} | ||
// get one path | ||
for (i = this.scopes.length - 1; i >= 0; i--) { | ||
var v = this.getPropertyByPath(this.scopes[i], str); | ||
if (v !== undefined) return v; | ||
if(this.opts.strict_variables){ | ||
throw new TypeError('undefined variable: ' + str); | ||
} | ||
}, | ||
get: function(str) { | ||
var val = this.safeGet(str); | ||
if (val === undefined && this.opts.strict) { | ||
throw new Error(`[strict_variables] undefined variable: ${str}`); | ||
} | ||
return val; | ||
}, | ||
set: function(k, v) { | ||
@@ -68,8 +63,10 @@ this.setPropertyByPath(this.scopes[this.scopes.length - 1], k, v); | ||
getPropertyByPath: function(obj, path) { | ||
if (_.isString(path) && path.length) { | ||
var paths = this.propertyAccessSeq(path); | ||
paths.forEach(p => obj = obj && obj[p]); | ||
return obj; | ||
var paths = this.propertyAccessSeq(path + ''); | ||
var varName = paths.shift(); | ||
if (!obj.hasOwnProperty(varName)) { | ||
throw new TypeError('undefined variable'); | ||
} | ||
return obj[path]; | ||
var variable = obj[varName]; | ||
paths.forEach(p => variable = variable[p]); | ||
return variable; | ||
}, | ||
@@ -100,7 +97,7 @@ | ||
// foo[1] | ||
if(lexical.isInteger(name)){ | ||
if (lexical.isInteger(name)) { | ||
seq.push(name); | ||
} | ||
// foo["bar"] | ||
else{ | ||
else { | ||
seq.push(this.get(name)); | ||
@@ -113,3 +110,3 @@ } | ||
else { | ||
var j = str.indexOf(delemiter, i + 2); | ||
j = str.indexOf(delemiter, i + 2); | ||
assert(j !== -1, `unbalanced ${delemiter}: ${str}`); | ||
@@ -153,11 +150,18 @@ name = str.slice(i + 2, j); | ||
exports.factory = function(_ctx, opts) { | ||
exports.factory = function(ctx, opts) { | ||
opts = _.assign({ | ||
strict: false | ||
strict_variables: false, | ||
strict_filters: false, | ||
blocks: {}, | ||
root: [] | ||
}, opts); | ||
ctx = _.assign(ctx, { | ||
liquid: opts | ||
}); | ||
var scope = Object.create(Scope); | ||
scope.opts = opts; | ||
scope.scopes = [_ctx || {}]; | ||
scope.scopes = [ctx]; | ||
return scope; | ||
}; |
@@ -21,5 +21,5 @@ const lexical = require('./lexical.js'); | ||
var _tagInstance = { | ||
render: function(scope, register) { | ||
render: function(scope) { | ||
var obj = hash(this.token.args, scope); | ||
return this.tagImpl.render && this.tagImpl.render(scope, obj, register) || Promise.resolve(''); | ||
return this.tagImpl.render && this.tagImpl.render(scope, obj) || Promise.resolve(''); | ||
}, | ||
@@ -26,0 +26,0 @@ parse: function(token, tokens){ |
@@ -17,19 +17,5 @@ const fs = require('fs'); | ||
function pathResolve(root, path) { | ||
if (path[0] == '/') return path; | ||
var arr = root.split('/').concat(path.split('/')); | ||
var result = []; | ||
arr.forEach(function(slug) { | ||
if (slug == '..') result.pop(); | ||
else if (!slug || slug == '.'); | ||
else result.push(slug); | ||
}); | ||
return '/' + result.join('/'); | ||
} | ||
module.exports = { | ||
readFileAsync, | ||
pathResolve, | ||
statFileAsync | ||
}; |
@@ -28,4 +28,24 @@ /* | ||
function assign(dst, src) { | ||
dst = dst || {}; | ||
/* | ||
* Assigns own enumerable string keyed properties of source objects to the destination object. | ||
* Source objects are applied from left to right. | ||
* Subsequent sources overwrite property assignments of previous sources. | ||
* | ||
* Note: This method mutates object and is loosely based on Object.assign. | ||
* | ||
* @param {Object} object The destination object. | ||
* @param {...Object} sources The source objects. | ||
* @return {Object} Returns object. | ||
*/ | ||
function assign(object) { | ||
object = isObject(object) ? object : {}; | ||
var srcs = Array.prototype.slice.call(arguments, 1); | ||
srcs.forEach(function(src) { | ||
_assignBinary(object, src); | ||
}); | ||
return object; | ||
} | ||
function _assignBinary(dst, src) { | ||
if (!dst) return dst; | ||
forOwn(src, function(v, k) { | ||
@@ -37,2 +57,3 @@ dst[k] = v; | ||
function isArray(value) { | ||
@@ -42,5 +63,40 @@ return value instanceof Array; | ||
function echo(prefix) { | ||
return v => { | ||
console.log('[' + prefix + ']', v); | ||
return v; | ||
}; | ||
} | ||
function uniq(arr) { | ||
var u = {}, | ||
a = []; | ||
for (var i = 0, l = arr.length; i < l; ++i) { | ||
if (u.hasOwnProperty(arr[i])) { | ||
continue; | ||
} | ||
a.push(arr[i]); | ||
u[arr[i]] = 1; | ||
} | ||
return a; | ||
} | ||
/* | ||
* Checks if value is the language type of Object. | ||
* (e.g. arrays, functions, objects, regexes, new Number(0), and new String('')) | ||
* @param {any} value The value to check. | ||
* @return {Boolean} Returns true if value is an object, else false. | ||
*/ | ||
function isObject(value) { | ||
return value !== null && typeof value === 'object'; | ||
} | ||
exports.isString = isString; | ||
exports.isArray = isArray; | ||
exports.isObject = isObject; | ||
exports.forOwn = forOwn; | ||
exports.assign = assign; | ||
exports.uniq = uniq; | ||
exports.echo = echo; |
@@ -27,5 +27,6 @@ const Liquid = require('..'); | ||
render: function(scope, hash, register) { | ||
render: function(scope, hash) { | ||
var group = Liquid.evalValue(this.group, scope); | ||
var fingerprint = `cycle:${group}:` + this.candidates.join(','); | ||
var register = scope.get('liquid'); | ||
var idx = register[fingerprint]; | ||
@@ -32,0 +33,0 @@ |
@@ -19,5 +19,9 @@ const Liquid = require('..'); | ||
}, | ||
render: function(scope, hash, register) { | ||
console.log('include', register.root); | ||
render: function(scope, hash) { | ||
var filepath = Liquid.evalValue(this.value, scope); | ||
var register = scope.get('liquid'); | ||
var originBlocks = register.blocks; | ||
register.blocks = {}; | ||
if(this.with){ | ||
@@ -33,2 +37,3 @@ hash[filepath] = Liquid.evalValue(this.with, scope); | ||
scope.pop(); | ||
register.blocks = originBlocks; | ||
return html; | ||
@@ -35,0 +40,0 @@ }); |
@@ -16,20 +16,16 @@ const Liquid = require('..'); | ||
}, | ||
render: function(scope) { | ||
render: function(scope, hash) { | ||
var layout = Liquid.evalValue(this.layout, scope); | ||
var register = scope.get('liquid'); | ||
var html = ''; | ||
scope.push({}); | ||
// not sure if this first one is needed, since the results are ignored | ||
// render the remaining tokens immediately | ||
return liquid.renderer.renderTemplates(this.tpls, scope) | ||
.then((partial) => { | ||
html += partial; | ||
return liquid.getTemplate(layout); | ||
}) | ||
.then((templates) => { | ||
return liquid.renderer.renderTemplates(templates, scope); | ||
}) | ||
.then((partial) => { | ||
scope.pop(); | ||
return partial; | ||
}); | ||
// now register.blocks contains rendered blocks | ||
.then(() => liquid.getTemplate(layout, register.root)) | ||
// push the hash | ||
.then(templates => (scope.push(hash), templates)) | ||
// render the parent | ||
.then(templates => liquid.renderer.renderTemplates(templates, scope)) | ||
// pop the hash | ||
.then(partial => (scope.pop(), partial)); | ||
} | ||
@@ -53,16 +49,17 @@ }); | ||
render: function(scope){ | ||
var html = scope.get(`_liquid.blocks.${this.block}`); | ||
var promise = Promise.resolve(''); | ||
var register = scope.get('liquid'); | ||
var html = register.blocks[this.block]; | ||
// if not defined yet | ||
if (html === undefined) { | ||
promise = liquid.renderer.renderTemplates(this.tpls, scope) | ||
return liquid.renderer.renderTemplates(this.tpls, scope) | ||
.then((partial) => { | ||
scope.set(`_liquid.blocks.${this.block}`, partial); | ||
register.blocks[this.block] = partial; | ||
return partial; | ||
}); | ||
} | ||
// if already defined by desendents | ||
else { | ||
scope.set(`_liquid.blocks.${this.block}`, html); | ||
promise = Promise.resolve(html); | ||
register.blocks[this.block] = html; | ||
return Promise.resolve(html); | ||
} | ||
return promise; | ||
} | ||
@@ -69,0 +66,0 @@ }); |
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
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
182565
3995
47
211