diff --git a/dist/liquid.js b/dist/liquid.js index c99fcb6f8..209f184ba 100644 --- a/dist/liquid.js +++ b/dist/liquid.js @@ -241,8 +241,8 @@ var _engine = { return this; }, - parse: function parse(html) { - var tokens = tokenizer.parse(html); + parse: function parse(html, filepath) { + var tokens = tokenizer.parse(html, filepath); return this.parser.parse(tokens); }, render: function render(tpl, ctx, opts) { @@ -270,9 +270,6 @@ var _engine = { opts = _.assign({}, opts); return this.getTemplate(filepath, opts.root).then(function (templates) { return _this2.render(templates, ctx, opts); - }).catch(function (e) { - e.file = filepath; - throw e; }); }, evalOutput: function evalOutput(str, scope) { @@ -321,7 +318,7 @@ var _engine = { }); } else { return readFileAsync(filepath).then(function (str) { - return _this3.parse(str); + return _this3.parse(str, filepath); }); } }); @@ -1198,7 +1195,7 @@ var TokenizationError = require('./util/error.js').TokenizationError; var _ = require('./util/underscore.js'); var assert = require('../src/util/assert.js'); -function parse(html) { +function parse(html, filepath) { assert(_.isString(html), 'illegal input type'); var tokens = []; @@ -1256,7 +1253,8 @@ function parse(html) { raw: match[offset], value: match[offset + 1].trim(), line: getLineNum(match), - input: html + input: html, + file: filepath }; } @@ -1300,9 +1298,10 @@ function TokenizationError(message, token) { this.input = token.input; this.line = token.line; + this.file = token.file; var context = mkContext(token.input, token.line); - this.message = message + ', line:' + token.line; + this.message = mkMessage(message, token); this.stack = context + '\n' + (this.stack || ''); } TokenizationError.prototype = Object.create(Error.prototype); @@ -1314,9 +1313,10 @@ function ParseError(e, token) { this.input = token.input; this.line = token.line; + this.file = token.file; var context = mkContext(token.input, token.line); - this.message = e.message + ', line:' + token.line; + this.message = mkMessage(e.message, token); this.stack = context + '\n' + (this.stack || ''); } ParseError.prototype = Object.create(Error.prototype); @@ -1332,9 +1332,10 @@ function RenderError(e, tpl) { this.input = tpl.token.input; this.line = tpl.token.line; + this.file = tpl.token.file; var context = mkContext(tpl.token.input, tpl.token.line); - this.message = e.message + ', line:' + tpl.token.line; + this.message = mkMessage(e.message, tpl.token); this.stack = context + '\n' + (e.stack || ''); } RenderError.prototype = Object.create(Error.prototype); @@ -1379,6 +1380,17 @@ function align(n, max) { return blank + str; } +function mkMessage(msg, token) { + msg = msg || ''; + if (token.file) { + msg += ', file:' + token.file; + } + if (token.line) { + msg += ', line:' + token.line; + } + return msg; +} + module.exports = { TokenizationError: TokenizationError, ParseError: ParseError, diff --git a/dist/liquid.min.js b/dist/liquid.min.js index 736c35a47..c2a6353b1 100644 --- a/dist/liquid.min.js +++ b/dist/liquid.min.js @@ -1,2 +1,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|"|'/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 e||t},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,"
")},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),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"),j=e("any-promise"),w=e("./src/util/promise.js").anySeries,x=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 j.resolve().then(function(){return n.parse(e)}).then(function(e){return n.render(e,t,r)})["catch"](function(e){if(e instanceof x.RenderBreakError)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?j.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:x.ParseError,TokenizationEroor:x.TokenizationError,RenderBreakError:x.RenderBreakError,AssertionError:x.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=e("./util/underscore.js"),o=new RegExp(""+r.value.source,"g");t.exports=function(e){function t(e){var t=Object.create(l);return t.parse(e)}function u(e,t){c[e]=t}function a(){c={}}e=i.assign({},e);var c={},l={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(t){var n=r.filterLine.exec(t);s(n,"illegal filter: "+t);var i=n[1],u=n[2]||"",a=c[i];if("function"!=typeof a){if(e.strict_filters)throw new TypeError("undefined filter: "+i);return this.name=i,this.filter=function(e){return e},this.args=[],this}for(var l=[];n=o.exec(u.trim());)l.push(n[0]);return this.name=i,this.filter=a,this.args=l,this}};return{construct:t,register:u,clear:a}}},{"./lexical.js":8,"./syntax.js":13,"./util/assert.js":16,"./util/underscore.js":21}],8:[function(e,t){"use strict";function r(e){return A.test(e)}function n(e){return S.test(e)}function s(e){return q.test(e)}function i(e){return R.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(P))?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+")*"),j=new RegExp("(?:"+y.source+"|"+h.source+")"),w=new RegExp("\\("+j.source+"\\.\\."+j.source+"\\)"),x=new RegExp("\\(("+j.source+")\\.\\.("+j.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"),R=new RegExp("^"+y.source+"$"),O=new RegExp("^"+h.source+"$"),M=new RegExp("^"+g.source+"$","i"),P=new RegExp("^"+l.source+"$"),q=new RegExp("^"+x.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:x,identifier:d,value:b,quoteBalanced:f,operators:_,quotedLine:P,numberLine:O,boolLine:M,rangeLine:q,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{var r=null;return r="tag"===e.type?u(e,t):"output"===e.type?a(e.value):e,r.token=e,r}catch(s){throw new n(s,e)}}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(l);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").RenderBreakError,a=e("./util/error.js").RenderError,c=e("./util/assert.js"),l={renderTemplates:function(e,t){function r(e){var r=this;return"tag"===e.type?this.renderTag(e,t).then(function(e){return void 0===e?"":e}):"output"===e.type?i.resolve().then(function(){return r.evalOutput(e,t)}).then(function(e){return void 0===e?"":n(e)}):i.resolve(e.value)}var s=this;c(t,"unable to evalTemplates: scope undefined");var l="";return o(e,function(e){return r.call(s,e).then(function(e){return l+=e})["catch"](function(t){if(t instanceof u)throw t.resolvedHTML=l,t;throw new a(t,e)})}).then(function(){return l})},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){return c(t,"unable to evalOutput: scope undefined"),e.filters.reduce(function(e,r){return r.render(e,t)},s.evalExp(e.initial,t))}};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=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(/undefined variable/.test(r.message))continue;if(/Cannot read property/.test(r.message)){if(this.opts.strict_variables)throw r.message+=": "+e,r;continue}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=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 i=r[1],u=r[2];s[i]=o.evalValue(u,t)}return s}var n=e("./lexical.js"),s=e("./util/underscore.js"),i=e("any-promise"),o=e("./syntax.js"),u=e("./util/assert.js");t.exports=function(){function e(e,t){o[e]=t}function t(e,t){var r=Object.create(a);return r.parse(e,t),r}function n(){o={}}var o={},a={render:function(e){var t=r(this.token.args,e),n=this.tagImpl;return"function"!=typeof n.render?i.resolve(""):i.resolve().then(function(){return"function"==typeof n.render?n.render(e,t):""})["catch"](function(e){if(s.isError(e))throw e;var t="Please reject with an Error in "+n.render+", got "+e;throw new Error(t)})},parse:function(e,t){this.type="tag",this.token=e,this.name=e.name;var r=o[this.name];u(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,"./util/underscore.js":21,"any-promise":3}],15:[function(e,t,r){"use strict";function n(e){function t(t,n,s){return{type:t,raw:s[n],value:s[n+1].trim(),line:r(s),input:e}}function r(e){var t=e.input.slice(h+1,e.index).split("\n");return g+=t.length-1,h=e.index,g+1}u(o.isString(e),"illegal input type");for(var n,a,c,l=[],f=/({%(.*?)%})|({{(.*?)}})/g,p=0,h=-1,g=0;null!==(n=f.exec(e));){if(n.index>p&&(a=e.slice(p,n.index),l.push({type:"html",raw:a,value:a})),n[1]){c=t("tag",1,n);var d=c.value.match(s.tagLine);if(!d)throw new i("illegal tag syntax",c);c.name=d[1],c.args=d[2],l.push(c)}else c=t("output",3,n),l.push(c);p=f.lastIndex}return e.length>p&&(a=e.slice(p,e.length),l.push({type:"html",raw:a,value:a})),l}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){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.input=t.input,this.line=t.line;var r=u(t.input,t.line);this.message=e+", line:"+t.line,this.stack=r+"\n"+(this.stack||"")}function n(e,t){this.name=this.constructor.name,this.stack=e.stack,this.input=t.input,this.line=t.line;var r=u(t.input,t.line);this.message=e.message+", line:"+t.line,this.stack=r+"\n"+(this.stack||"")}function s(e,t){if(e instanceof s)return e;this.name=this.constructor.name,this.stack=e.stack,this.input=t.token.input,this.line=t.token.line;var r=u(t.token.input,t.token.line);this.message=e.message+", line:"+t.token.line,this.stack=r+"\n"+(e.stack||"")}function i(e){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.message=e||""}function o(e){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.message=e}function u(e,t){var r=e.split("\n"),n=Math.max(t-2,1),s=Math.min(t+3,r.length),i=c.range(n,s+1).map(function(e){return[e===t?">> ":" ",a(e,s),"| ",r[e-1]].join("")}).join("\n");return i}function a(e,t){var r=(t+"").length,n=e+"",s=Array(r-n.length).join(" ");return s+n}var c=e("./underscore.js");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,o.prototype=Object.create(Error.prototype),o.prototype.constructor=o,t.exports={TokenizationError:r,ParseError:n,RenderBreakError:i,AssertionError:o,RenderError:s}},{"./underscore.js":21}],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;r0;)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){var t=Object.prototype.toString.call(e);return"Error"===t.substr(-6,5)||"string"==typeof e.message&&"string"==typeof e.name}function i(e,t){e=e||{};for(var r in e)if(e.hasOwnProperty(r)&&t(e[r],r,e)===!1)break;return e}function o(e){e=f(e)?e:{};var t=Array.prototype.slice.call(arguments,1);return t.forEach(function(t){u(e,t)}),e}function u(e,t){return e?(i(t,function(t,r){e[r]=t}),e):e}function a(e){return e instanceof Array}function c(e){return function(t){return console.log("["+e+"]",t),t}}function l(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 f(e){return null!==e&&"object"===("undefined"==typeof e?"undefined":h(e))}function p(e,t,r){1===arguments.length&&(t=e,e=0),r=r||1;for(var n=[],s=e;t>s;s+=r)n.push(s);return n}var h="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=a,r.isObject=f,r.isError=s,r.range=p,r.forOwn=i,r.assign=o,r.uniq=l,r.echo=c},{}],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",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+=""),c+=''),c+=''}).then(function(){return t.push(n),e.renderer.renderTemplates(u.templates,t)}).then(function(e){return t.pop(n),c+=e,c+=""})},n.resolve(""));return g.then(function(){return i>0&&(c+=""),c+=""})["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)}); \ No newline at end of file +!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|"|'/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 e||t},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,"
")},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),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"),j=e("any-promise"),w=e("./src/util/promise.js").anySeries,x=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,t){var r=u.parse(e,t);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 j.resolve().then(function(){return n.parse(e)}).then(function(e){return n.render(e,t,r)})["catch"](function(e){if(e instanceof x.RenderBreakError)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)})},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?j.resolve(t):c(e).then(function(e){return r.parse(e)}).then(function(t){return r.cache[e]=t})}return c(e).then(function(t){return r.parse(t,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:x.ParseError,TokenizationEroor:x.TokenizationError,RenderBreakError:x.RenderBreakError,AssertionError:x.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=e("./util/underscore.js"),o=new RegExp(""+r.value.source,"g");t.exports=function(e){function t(e){var t=Object.create(l);return t.parse(e)}function u(e,t){c[e]=t}function a(){c={}}e=i.assign({},e);var c={},l={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(t){var n=r.filterLine.exec(t);s(n,"illegal filter: "+t);var i=n[1],u=n[2]||"",a=c[i];if("function"!=typeof a){if(e.strict_filters)throw new TypeError("undefined filter: "+i);return this.name=i,this.filter=function(e){return e},this.args=[],this}for(var l=[];n=o.exec(u.trim());)l.push(n[0]);return this.name=i,this.filter=a,this.args=l,this}};return{construct:t,register:u,clear:a}}},{"./lexical.js":8,"./syntax.js":13,"./util/assert.js":16,"./util/underscore.js":21}],8:[function(e,t){"use strict";function r(e){return A.test(e)}function n(e){return S.test(e)}function s(e){return q.test(e)}function i(e){return R.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(P))?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+")*"),j=new RegExp("(?:"+y.source+"|"+h.source+")"),w=new RegExp("\\("+j.source+"\\.\\."+j.source+"\\)"),x=new RegExp("\\(("+j.source+")\\.\\.("+j.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"),R=new RegExp("^"+y.source+"$"),O=new RegExp("^"+h.source+"$"),M=new RegExp("^"+g.source+"$","i"),P=new RegExp("^"+l.source+"$"),q=new RegExp("^"+x.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:x,identifier:d,value:b,quoteBalanced:f,operators:_,quotedLine:P,numberLine:O,boolLine:M,rangeLine:q,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{var r=null;return r="tag"===e.type?u(e,t):"output"===e.type?a(e.value):e,r.token=e,r}catch(s){throw new n(s,e)}}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(l);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").RenderBreakError,a=e("./util/error.js").RenderError,c=e("./util/assert.js"),l={renderTemplates:function(e,t){function r(e){var r=this;return"tag"===e.type?this.renderTag(e,t).then(function(e){return void 0===e?"":e}):"output"===e.type?i.resolve().then(function(){return r.evalOutput(e,t)}).then(function(e){return void 0===e?"":n(e)}):i.resolve(e.value)}var s=this;c(t,"unable to evalTemplates: scope undefined");var l="";return o(e,function(e){return r.call(s,e).then(function(e){return l+=e})["catch"](function(t){if(t instanceof u)throw t.resolvedHTML=l,t;throw new a(t,e)})}).then(function(){return l})},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){return c(t,"unable to evalOutput: scope undefined"),e.filters.reduce(function(e,r){return r.render(e,t)},s.evalExp(e.initial,t))}};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=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(/undefined variable/.test(r.message))continue;if(/Cannot read property/.test(r.message)){if(this.opts.strict_variables)throw r.message+=": "+e,r;continue}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=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 i=r[1],u=r[2];s[i]=o.evalValue(u,t)}return s}var n=e("./lexical.js"),s=e("./util/underscore.js"),i=e("any-promise"),o=e("./syntax.js"),u=e("./util/assert.js");t.exports=function(){function e(e,t){o[e]=t}function t(e,t){var r=Object.create(a);return r.parse(e,t),r}function n(){o={}}var o={},a={render:function(e){var t=r(this.token.args,e),n=this.tagImpl;return"function"!=typeof n.render?i.resolve(""):i.resolve().then(function(){return"function"==typeof n.render?n.render(e,t):""})["catch"](function(e){if(s.isError(e))throw e;var t="Please reject with an Error in "+n.render+", got "+e;throw new Error(t)})},parse:function(e,t){this.type="tag",this.token=e,this.name=e.name;var r=o[this.name];u(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,"./util/underscore.js":21,"any-promise":3}],15:[function(e,t,r){"use strict";function n(e,t){function r(r,s,i){return{type:r,raw:i[s],value:i[s+1].trim(),line:n(i),input:e,file:t}}function n(e){var t=e.input.slice(g+1,e.index).split("\n");return d+=t.length-1,g=e.index,d+1}u(o.isString(e),"illegal input type");for(var a,c,l,f=[],p=/({%(.*?)%})|({{(.*?)}})/g,h=0,g=-1,d=0;null!==(a=p.exec(e));){if(a.index>h&&(c=e.slice(h,a.index),f.push({type:"html",raw:c,value:c})),a[1]){l=r("tag",1,a);var v=l.value.match(s.tagLine);if(!v)throw new i("illegal tag syntax",l);l.name=v[1],l.args=v[2],f.push(l)}else l=r("output",3,a),f.push(l);h=p.lastIndex}return e.length>h&&(c=e.slice(h,e.length),f.push({type:"html",raw:c,value:c})),f}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){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.input=t.input,this.line=t.line,this.file=t.file;var r=u(t.input,t.line);this.message=c(e,t),this.stack=r+"\n"+(this.stack||"")}function n(e,t){this.name=this.constructor.name,this.stack=e.stack,this.input=t.input,this.line=t.line,this.file=t.file;var r=u(t.input,t.line);this.message=c(e.message,t),this.stack=r+"\n"+(this.stack||"")}function s(e,t){if(e instanceof s)return e;this.name=this.constructor.name,this.stack=e.stack,this.input=t.token.input,this.line=t.token.line,this.file=t.token.file;var r=u(t.token.input,t.token.line);this.message=c(e.message,t.token),this.stack=r+"\n"+(e.stack||"")}function i(e){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.message=e||""}function o(e){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.message=e}function u(e,t){var r=e.split("\n"),n=Math.max(t-2,1),s=Math.min(t+3,r.length),i=l.range(n,s+1).map(function(e){return[e===t?">> ":" ",a(e,s),"| ",r[e-1]].join("")}).join("\n");return i}function a(e,t){var r=(t+"").length,n=e+"",s=Array(r-n.length).join(" ");return s+n}function c(e,t){return e=e||"",t.file&&(e+=", file:"+t.file),t.line&&(e+=", line:"+t.line),e}var l=e("./underscore.js");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,o.prototype=Object.create(Error.prototype),o.prototype.constructor=o,t.exports={TokenizationError:r,ParseError:n,RenderBreakError:i,AssertionError:o,RenderError:s}},{"./underscore.js":21}],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;r0;)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){var t=Object.prototype.toString.call(e);return"Error"===t.substr(-6,5)||"string"==typeof e.message&&"string"==typeof e.name}function i(e,t){e=e||{};for(var r in e)if(e.hasOwnProperty(r)&&t(e[r],r,e)===!1)break;return e}function o(e){e=f(e)?e:{};var t=Array.prototype.slice.call(arguments,1);return t.forEach(function(t){u(e,t)}),e}function u(e,t){return e?(i(t,function(t,r){e[r]=t}),e):e}function a(e){return e instanceof Array}function c(e){return function(t){return console.log("["+e+"]",t),t}}function l(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 f(e){return null!==e&&"object"===("undefined"==typeof e?"undefined":h(e))}function p(e,t,r){1===arguments.length&&(t=e,e=0),r=r||1;for(var n=[],s=e;t>s;s+=r)n.push(s);return n}var h="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=a,r.isObject=f,r.isError=s,r.range=p,r.forOwn=i,r.assign=o,r.uniq=l,r.echo=c},{}],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",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+=""),c+=''),c+=''}).then(function(){return t.push(n),e.renderer.renderTemplates(u.templates,t)}).then(function(e){return t.pop(n),c+=e,c+=""})},n.resolve(""));return g.then(function(){return i>0&&(c+=""),c+=""})["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)}); \ No newline at end of file diff --git a/package.json b/package.json index 162dcdfe1..fc4b70881 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "shopify-liquid", - "version": "1.5.1", + "version": "1.5.2", "description": "A feature-rich Liquid template engine for Node.js and browsers, with compliance with the Ruby version.", "main": "index.js", "scripts": {