Socket
Socket
Sign inDemoInstall

nunjucks

Package Overview
Dependencies
Maintainers
5
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nunjucks - npm Package Compare versions

Comparing version 3.2.3 to 3.2.4

4

browser/nunjucks-slim.min.js

@@ -1,3 +0,3 @@

/*! Browser bundle of nunjucks 3.2.3 (slim, only works with precompiled templates) */
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.nunjucks=n():t.nunjucks=n()}("undefined"!=typeof self?self:this,function(){return function(t){var n={};function r(i){if(n[i])return n[i].exports;var e=n[i]={i:i,l:!1,exports:{}};return t[i].call(e.exports,e,e.exports,r),e.l=!0,e.exports}return r.m=t,r.c=n,r.d=function(t,n,i){r.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="",r(r.s=6)}([function(t,n){},function(t,n,r){"use strict";var i=Array.prototype,e=Object.prototype,u={"&":"&amp;",'"':"&quot;","'":"&#39;","<":"&lt;",">":"&gt;"},o=/[&"'<>]/g;function f(t,n){return e.hasOwnProperty.call(t,n)}function c(t){return u[t]}function s(t,n,r){var i,e,u;if(t instanceof Error&&(t=(e=t).name+": "+e.message),Object.setPrototypeOf?Object.setPrototypeOf(i=Error(t),s.prototype):Object.defineProperty(i=this,"message",{enumerable:!1,writable:!0,value:t}),Object.defineProperty(i,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(i,this.constructor),e){var o=Object.getOwnPropertyDescriptor(e,"stack");(u=o&&(o.get||function(){return o.value}))||(u=function(){return e.stack})}else{var f=Error(t).stack;u=function(){return f}}return Object.defineProperty(i,"stack",{get:function(){return u.call(i)}}),Object.defineProperty(i,"cause",{value:e}),i.lineno=n,i.colno=r,i.firstUpdate=!0,i.Update=function(t){var n="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?n+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(n+=" [Line "+this.lineno+"]")),n+="\n ",this.firstUpdate&&(n+=" "),this.message=n+(this.message||""),this.firstUpdate=!1,this},i}function a(t){return"[object Function]"===e.toString.call(t)}function h(t){return"[object Array]"===e.toString.call(t)}function v(t){return"[object String]"===e.toString.call(t)}function l(t){return"[object Object]"===e.toString.call(t)}function d(t){var n,r=(n=t)?"string"==typeof n?n.split("."):[n]:[];return function(t){for(var n=t,i=0;i<r.length;i++){var e=r[i];if(!f(n,e))return;n=n[e]}return n}}function p(t){return Array.prototype.slice.call(t)}function y(t,n,r){return Array.prototype.indexOf.call(t||[],n,r)}function b(t){var n=[];for(var r in t)f(t,r)&&n.push(r);return n}(n=t.exports={}).hasOwnProp=f,n.t=function(t,r,i){if(i.Update||(i=new n.TemplateError(i)),i.Update(t),!r){var e=i;(i=Error(e.message)).name=e.name}return i},Object.setPrototypeOf?Object.setPrototypeOf(s.prototype,Error.prototype):s.prototype=Object.create(Error.prototype,{constructor:{value:s}}),n.TemplateError=s,n.escape=function(t){return t.replace(o,c)},n.isFunction=a,n.isArray=h,n.isString=v,n.isObject=l,n.getAttrGetter=d,n.groupBy=function(t,n,r){for(var i={},e=a(n)?n:d(n),u=0;u<t.length;u++){var o=t[u],f=e(o,u);if(void 0===f&&!0===r)throw new TypeError('groupby: attribute "'+n+'" resolved to undefined');(i[f]||(i[f]=[])).push(o)}return i},n.toArray=p,n.without=function(t){var n=[];if(!t)return n;for(var r=t.length,i=p(arguments).slice(1),e=-1;++e<r;)-1===y(i,t[e])&&n.push(t[e]);return n},n.repeat=function(t,n){for(var r="",i=0;i<n;i++)r+=t;return r},n.each=function(t,n,r){if(null!=t)if(i.forEach&&t.forEach===i.forEach)t.forEach(n,r);else if(t.length===+t.length)for(var e=0,u=t.length;e<u;e++)n.call(r,t[e],e,t)},n.map=function(t,n){var r=[];if(null==t)return r;if(i.map&&t.map===i.map)return t.map(n);for(var e=0;e<t.length;e++)r[r.length]=n(t[e],e);return t.length===+t.length&&(r.length=t.length),r},n.asyncIter=function(t,n,r){var i=-1;!function e(){++i<t.length?n(t[i],i,e,r):r()}()},n.asyncFor=function(t,n,r){var i=b(t||{}),e=i.length,u=-1;!function o(){var f=i[++u];u<e?n(f,t[f],u,e,o):r()}()},n.indexOf=y,n.keys=b,n.r=function(t){return b(t).map(function(n){return[n,t[n]]})},n.u=function(t){return b(t).map(function(n){return t[n]})},n.f=n.extend=function(t,n){return t=t||{},b(n).forEach(function(r){t[r]=n[r]}),t},n.inOperator=function(t,n){if(h(n)||v(n))return-1!==n.indexOf(t);if(l(n))return t in n;throw Error('Cannot use "in" operator to search for "'+t+'" in unexpected types.')}},function(t,n,r){"use strict";var i=r(1),e=Array.from,u="function"==typeof Symbol&&Symbol.iterator&&"function"==typeof e,o=function(){function t(t,n){this.variables=Object.create(null),this.parent=t,this.topLevel=!1,this.isolateWrites=n}var n=t.prototype;return n.set=function(t,n,r){var i=t.split("."),e=this.variables,u=this;if(r&&(u=this.resolve(i[0],!0)))u.set(t,n);else{for(var o=0;o<i.length-1;o++){var f=i[o];e[f]||(e[f]={}),e=e[f]}e[i[i.length-1]]=n}},n.get=function(t){var n=this.variables[t];return void 0!==n?n:null},n.lookup=function(t){var n=this.parent,r=this.variables[t];return void 0!==r?r:n&&n.lookup(t)},n.resolve=function(t,n){var r=n&&this.isolateWrites?void 0:this.parent;return void 0!==this.variables[t]?this:r&&r.resolve(t)},n.push=function(n){return new t(this,n)},n.pop=function(){return this.parent},t}();function f(t){return t&&Object.prototype.hasOwnProperty.call(t,"__keywords")}function c(t){var n=t.length;return 0===n?0:f(t[n-1])?n-1:n}function s(t){if("string"!=typeof t)return t;this.val=t,this.length=t.length}s.prototype=Object.create(String.prototype,{length:{writable:!0,configurable:!0,value:0}}),s.prototype.valueOf=function(){return this.val},s.prototype.toString=function(){return this.val},t.exports={Frame:o,makeMacro:function(t,n,r){return function(){for(var i=arguments.length,e=Array(i),u=0;u<i;u++)e[u]=arguments[u];var o,s=c(e),a=function(t){var n=t.length;if(n){var r=t[n-1];if(f(r))return r}return{}}(e);if(s>t.length)o=e.slice(0,t.length),e.slice(o.length,s).forEach(function(t,r){r<n.length&&(a[n[r]]=t)}),o.push(a);else if(s<t.length){o=e.slice(0,s);for(var h=s;h<t.length;h++){var v=t[h];o.push(a[v]),delete a[v]}o.push(a)}else o=e;return r.apply(this,o)}},makeKeywordArgs:function(t){return t.__keywords=!0,t},numArgs:c,suppressValue:function(t,n){return t=void 0!==t&&null!==t?t:"",!n||t instanceof s||(t=i.escape(t.toString())),t},ensureDefined:function(t,n,r){if(null===t||void 0===t)throw new i.TemplateError("attempted to output null or undefined value",n+1,r+1);return t},memberLookup:function(t,n){if(void 0!==t&&null!==t)return"function"==typeof t[n]?function(){for(var r=arguments.length,i=Array(r),e=0;e<r;e++)i[e]=arguments[e];return t[n].apply(t,i)}:t[n]},contextOrFrameLookup:function(t,n,r){var i=n.lookup(r);return void 0!==i?i:t.lookup(r)},callWrap:function(t,n,r,i){if(!t)throw Error("Unable to call `"+n+"`, which is undefined or falsey");if("function"!=typeof t)throw Error("Unable to call `"+n+"`, which is not a function");return t.apply(r,i)},handleError:function(t,n,r){return t.lineno?t:new i.TemplateError(t,n,r)},isArray:i.isArray,keys:i.keys,SafeString:s,copySafeness:function(t,n){return t instanceof s?new s(n):n.toString()},markSafe:function(t){var n=typeof t;return"string"===n?new s(t):"function"!==n?t:function(n){var r=t.apply(this,arguments);return"string"==typeof r?new s(r):r}},asyncEach:function(t,n,r,e){if(i.isArray(t)){var u=t.length;i.asyncIter(t,function(t,i,e){switch(n){case 1:r(t,i,u,e);break;case 2:r(t[0],t[1],i,u,e);break;case 3:r(t[0],t[1],t[2],i,u,e);break;default:t.push(i,u,e),r.apply(this,t)}},e)}else i.asyncFor(t,function(t,n,i,e,u){r(t,n,i,e,u)},e)},asyncAll:function(t,n,r,e){var u,o,f=0;function c(t,n){f++,o[t]=n,f===u&&e(null,o.join(""))}if(i.isArray(t))if(u=t.length,o=Array(u),0===u)e(null,"");else for(var s=0;s<t.length;s++){var a=t[s];switch(n){case 1:r(a,s,u,c);break;case 2:r(a[0],a[1],s,u,c);break;case 3:r(a[0],a[1],a[2],s,u,c);break;default:a.push(s,u,c),r.apply(this,a)}}else{var h=i.keys(t||{});if(u=h.length,o=Array(u),0===u)e(null,"");else for(var v=0;v<h.length;v++){var l=h[v];r(l,t[l],v,u,c)}}},inOperator:i.inOperator,fromIterator:function(t){return"object"!=typeof t||null===t||i.isArray(t)?t:u&&Symbol.iterator in t?e(t):t}}},function(t,n,r){"use strict";function i(t,n){return(i=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t})(t,n)}var e=function(t){var n,r;function e(n){var r;return(r=t.call(this)||this).precompiled=n||{},r}return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,i(n,r),e.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},e}(r(4));t.exports={PrecompiledLoader:e}},function(t,n,r){"use strict";function i(t,n){return(i=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t})(t,n)}var e=r(0),u=r(5).EmitterObj;t.exports=function(t){var n,r;function u(){return t.apply(this,arguments)||this}r=t,(n=u).prototype=Object.create(r.prototype),n.prototype.constructor=n,i(n,r);var o=u.prototype;return o.resolve=function(t,n){return e.resolve(e.dirname(t),n)},o.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},u}(u)},function(t,n,r){"use strict";function i(t,n){for(var r=0;r<n.length;r++){var i=n[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function e(t,n,r){return n&&i(t.prototype,n),r&&i(t,r),t}function u(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,o(t,n)}function o(t,n){return(o=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t})(t,n)}var f=r(13),c=r(1);function s(t,n,r){r=r||{},c.keys(r).forEach(function(n){var i,e;r[n]=(i=t.prototype[n],e=r[n],"function"!=typeof i||"function"!=typeof e?e:function(){var t=this.parent;this.parent=i;var n=e.apply(this,arguments);return this.parent=t,n})});var i=function(t){function r(){return t.apply(this,arguments)||this}return u(r,t),e(r,[{key:"typename",get:function(){return n}}]),r}(t);return c.f(i.prototype,r),i}var a=function(){function t(){this.init.apply(this,arguments)}return t.prototype.init=function(){},t.extend=function(t,n){return"object"==typeof t&&(n=t,t="anonymous"),s(this,t,n)},e(t,[{key:"typename",get:function(){return this.constructor.name}}]),t}(),h=function(t){function n(){var n,r;return(n=r=t.call(this)||this).init.apply(n,arguments),r}return u(n,t),n.prototype.init=function(){},n.extend=function(t,n){return"object"==typeof t&&(n=t,t="anonymous"),s(this,t,n)},e(n,[{key:"typename",get:function(){return this.constructor.name}}]),n}(f);t.exports={Obj:a,EmitterObj:h}},function(t,n,r){"use strict";var i,e=r(1),u=r(7),o=u.Environment,f=u.Template,c=r(4),s=r(3),a=r(0),h=r(0),v=r(0),l=r(0),d=r(2),p=r(0),y=r(17);function b(t,n){var r;return n=n||{},e.isObject(t)&&(n=t,t=null),s.FileSystemLoader?r=new s.FileSystemLoader(t,{watch:n.watch,noCache:n.noCache}):s.WebLoader&&(r=new s.WebLoader(t,{useCache:n.web&&n.web.useCache,async:n.web&&n.web.async})),i=new o(r,n),n&&n.express&&i.express(n.express),i}t.exports={Environment:o,Template:f,Loader:c,FileSystemLoader:s.FileSystemLoader,NodeResolveLoader:s.NodeResolveLoader,PrecompiledLoader:s.PrecompiledLoader,WebLoader:s.WebLoader,compiler:h,parser:v,lexer:l,runtime:d,lib:e,nodes:p,installJinjaCompat:y,configure:b,reset:function(){i=void 0},compile:function(t,n,r,e){return i||b(),new f(t,n,r,e)},render:function(t,n,r){return i||b(),i.render(t,n,r)},renderString:function(t,n,r){return i||b(),i.renderString(t,n,r)},precompile:a?a.precompile:void 0,precompileString:a?a.precompileString:void 0}},function(t,n,r){"use strict";function i(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,e(t,n)}function e(t,n){return(e=Object.setPrototypeOf||function(t,n){return t.__proto__=n,t})(t,n)}var u=r(8),o=r(11),f=r(1),c=r(0),s=r(12),a=r(3),h=a.FileSystemLoader,v=a.WebLoader,l=a.PrecompiledLoader,d=r(14),p=r(15),y=r(5),b=y.Obj,w=y.EmitterObj,m=r(2),j=m.handleError,g=m.Frame,E=r(16);function O(t,n,r){u(function(){t(n,r)})}var k={type:"code",obj:{root:function(t,n,r,i,e){try{e(null,"")}catch(t){e(j(t,null,null))}}}},A=function(t){function n(){return t.apply(this,arguments)||this}i(n,t);var r=n.prototype;return r.init=function(t,n){var r=this;n=this.opts=n||{},this.opts.dev=!!n.dev,this.opts.autoescape=null==n.autoescape||n.autoescape,this.opts.throwOnUndefined=!!n.throwOnUndefined,this.opts.trimBlocks=!!n.trimBlocks,this.opts.lstripBlocks=!!n.lstripBlocks,this.loaders=[],t?this.loaders=f.isArray(t)?t:[t]:h?this.loaders=[new h("views")]:v&&(this.loaders=[new v("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new l(window.nunjucksPrecompiled)),this.a(),this.globals=p(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],f.r(s).forEach(function(t){var n=t[0],i=t[1];return r.addFilter(n,i)}),f.r(d).forEach(function(t){var n=t[0],i=t[1];return r.addTest(n,i)})},r.a=function(){var t=this;this.loaders.forEach(function(n){n.cache={},"function"==typeof n.on&&(n.on("update",function(r,i){n.cache[r]=null,t.emit("update",r,i,n)}),n.on("load",function(r,i){t.emit("load",r,i,n)}))})},r.invalidateCache=function(){this.loaders.forEach(function(t){t.cache={}})},r.addExtension=function(t,n){return n.__name=t,this.extensions[t]=n,this.extensionsList.push(n),this},r.removeExtension=function(t){var n=this.getExtension(t);n&&(this.extensionsList=f.without(this.extensionsList,n),delete this.extensions[t])},r.getExtension=function(t){return this.extensions[t]},r.hasExtension=function(t){return!!this.extensions[t]},r.addGlobal=function(t,n){return this.globals[t]=n,this},r.getGlobal=function(t){if(void 0===this.globals[t])throw Error("global not found: "+t);return this.globals[t]},r.addFilter=function(t,n,r){var i=n;return r&&this.asyncFilters.push(t),this.filters[t]=i,this},r.getFilter=function(t){if(!this.filters[t])throw Error("filter not found: "+t);return this.filters[t]},r.addTest=function(t,n){return this.tests[t]=n,this},r.getTest=function(t){if(!this.tests[t])throw Error("test not found: "+t);return this.tests[t]},r.resolveTemplate=function(t,n,r){return!(!t.isRelative||!n)&&t.isRelative(r)&&t.resolve?t.resolve(n,r):r},r.getTemplate=function(t,n,r,i,e){var u,o=this,c=this,s=null;if(t&&t.raw&&(t=t.raw),f.isFunction(r)&&(e=r,r=null,n=n||!1),f.isFunction(n)&&(e=n,n=!1),t instanceof L)s=t;else{if("string"!=typeof t)throw Error("template names must be a string: "+t);for(var a=0;a<this.loaders.length;a++){var h=this.loaders[a];if(s=h.cache[this.resolveTemplate(h,r,t)])break}}if(s)return n&&s.compile(),e?void e(null,s):s;return f.asyncIter(this.loaders,function(n,i,e,u){function o(t,r){t?u(t):r?(r.loader=n,u(null,r)):e()}t=c.resolveTemplate(n,r,t),n.async?n.getSource(t,o):o(null,n.getSource(t))},function(r,f){if(f||r||i||(r=Error("template not found: "+t)),r){if(e)return void e(r);throw r}var c;f?(c=new L(f.src,o,f.path,n),f.noCache||(f.loader.cache[t]=c)):c=new L(k,o,"",n),e?e(null,c):u=c}),u},r.express=function(t){return E(this,t)},r.render=function(t,n,r){f.isFunction(n)&&(r=n,n=null);var i=null;return this.getTemplate(t,function(t,e){if(t&&r)O(r,t);else{if(t)throw t;i=e.render(n,r)}}),i},r.renderString=function(t,n,r,i){return f.isFunction(r)&&(i=r,r={}),new L(t,this,(r=r||{}).path).render(n,i)},r.waterfall=function(t,n,r){return o(t,n,r)},n}(w),S=function(t){function n(){return t.apply(this,arguments)||this}i(n,t);var r=n.prototype;return r.init=function(t,n,r){var i=this;this.env=r||new A,this.ctx=f.extend({},t),this.blocks={},this.exported=[],f.keys(n).forEach(function(t){i.addBlock(t,n[t])})},r.lookup=function(t){return t in this.env.globals&&!(t in this.ctx)?this.env.globals[t]:this.ctx[t]},r.setVariable=function(t,n){this.ctx[t]=n},r.getVariables=function(){return this.ctx},r.addBlock=function(t,n){return this.blocks[t]=this.blocks[t]||[],this.blocks[t].push(n),this},r.getBlock=function(t){if(!this.blocks[t])throw Error('unknown block "'+t+'"');return this.blocks[t][0]},r.getSuper=function(t,n,r,i,e,u){var o=f.indexOf(this.blocks[n]||[],r),c=this.blocks[n][o+1];if(-1===o||!c)throw Error('no super block available for "'+n+'"');c(t,this,i,e,u)},r.addExport=function(t){this.exported.push(t)},r.getExported=function(){var t=this,n={};return this.exported.forEach(function(r){n[r]=t.ctx[r]}),n},n}(b),L=function(t){function n(){return t.apply(this,arguments)||this}i(n,t);var r=n.prototype;return r.init=function(t,n,r,i){if(this.env=n||new A,f.isObject(t))switch(t.type){case"code":this.tmplProps=t.obj;break;case"string":this.tmplStr=t.obj;break;default:throw Error("Unexpected template object type "+t.type+"; expected 'code', or 'string'")}else{if(!f.isString(t))throw Error("src must be a string or an object describing the source");this.tmplStr=t}if(this.path=r,i)try{this.h()}catch(t){throw f.t(this.path,this.env.opts.dev,t)}else this.compiled=!1},r.render=function(t,n,r){var i=this;"function"==typeof t?(r=t,t={}):"function"==typeof n&&(r=n,n=null);var e=!n;try{this.compile()}catch(t){var u=f.t(this.path,this.env.opts.dev,t);if(r)return O(r,u);throw u}var o=new S(t||{},this.blocks,this.env),c=n?n.push(!0):new g;c.topLevel=!0;var s=null,a=!1;return this.rootRenderFunc(this.env,o,c,m,function(t,n){if(!a||!r||void 0===n)if(t&&(t=f.t(i.path,i.env.opts.dev,t),a=!0),r)e?O(r,t,n):r(t,n);else{if(t)throw t;s=n}}),s},r.getExported=function(t,n,r){"function"==typeof t&&(r=t,t={}),"function"==typeof n&&(r=n,n=null);try{this.compile()}catch(t){if(r)return r(t);throw t}var i=n?n.push():new g;i.topLevel=!0;var e=new S(t||{},this.blocks,this.env);this.rootRenderFunc(this.env,e,i,m,function(t){t?r(t,null):r(null,e.getExported())})},r.compile=function(){this.compiled||this.h()},r.h=function(){var t;if(this.tmplProps)t=this.tmplProps;else{var n=c.compile(this.tmplStr,this.env.asyncFilters,this.env.extensionsList,this.path,this.env.opts);t=Function(n)()}this.blocks=this.v(t),this.rootRenderFunc=t.root,this.compiled=!0},r.v=function(t){var n={};return f.keys(t).forEach(function(r){"b_"===r.slice(0,2)&&(n[r.slice(2)]=t[r])}),n},n}(b);t.exports={Environment:A,Template:L}},function(t,n,r){"use strict";var i=r(9),e=[],u=[],o=i.makeRequestCallFromTimer(function(){if(u.length)throw u.shift()});function f(t){var n;(n=e.length?e.pop():new c).task=t,i(n)}function c(){this.task=null}t.exports=f,c.prototype.call=function(){try{this.task.call()}catch(t){f.onerror?f.onerror(t):(u.push(t),o())}finally{this.task=null,e[e.length]=this}}},function(t,n,r){"use strict";!function(n){function r(t){e.length||(i(),!0),e[e.length]=t}t.exports=r;var i,e=[],u=0,o=1024;function f(){for(;u<e.length;){var t=u;if(u+=1,e[t].call(),u>o){for(var n=0,r=e.length-u;n<r;n++)e[n]=e[n+u];e.length-=u,u=0}}e.length=0,u=0,!1}var c,s,a,h=void 0!==n?n:self,v=h.MutationObserver||h.WebKitMutationObserver;function l(t){return function(){var n=setTimeout(i,0),r=setInterval(i,50);function i(){clearTimeout(n),clearInterval(r),t()}}}"function"==typeof v?(c=1,s=new v(f),a=document.createTextNode(""),s.observe(a,{characterData:!0}),i=function(){c=-c,a.data=c}):i=l(f),r.requestFlush=i,r.makeRequestCallFromTimer=l}(r(10))},function(t,n){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,n,r){var i;!function(r){"use strict";var e=function(){var t=Array.prototype.slice.call(arguments);"function"==typeof t[0]&&t[0].apply(null,t.splice(1))},u=function(t){"function"==typeof setImmediate?setImmediate(t):"undefined"!=typeof process&&process.nextTick?process.nextTick(t):setTimeout(t,0)},o=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},f=function(t,n,r){var i=r?u:e;if(n=n||function(){},!o(t))return n(Error("First argument to waterfall must be an array of functions"));if(!t.length)return n();var f=function(t){return function(r){if(r)n.apply(null,arguments),n=function(){};else{var e=Array.prototype.slice.call(arguments,1),u=t.next();u?e.push(f(u)):e.push(n),i(function(){t.apply(null,e)})}}};f(function(t){var n=function(r){var i=function(){return t.length&&t[r].apply(null,arguments),i.next()};return i.next=function(){return r<t.length-1?n(r+1):null},i};return n(0)}(t))()};void 0===(i=function(){return f}.apply(n,[]))||(t.exports=i)}()},function(t,n,r){"use strict";var i=r(1),e=r(2);function u(t,n){return null===t||void 0===t||!1===t?n:t}function o(t){return t!=t}function f(t){var n=(t=u(t,"")).toLowerCase();return e.copySafeness(t,n.charAt(0).toUpperCase()+n.slice(1))}function c(t){if(i.isString(t))return t.split("");if(i.isObject(t))return i.r(t||{}).map(function(t){return{key:t[0],value:t[1]}});if(i.isArray(t))return t;throw new i.TemplateError("list filter: type not iterable")}function s(t){return function(n,r,e){void 0===r&&(r="truthy");var u=this,o=u.env.getTest(r);return i.toArray(n).filter(function(n){return o.call(u,n,e)===t})}}function a(t){return e.copySafeness(t,t.replace(/^\s*|\s*$/g,""))}(n=t.exports={}).abs=Math.abs,n.batch=function(t,n,r){var i,e=[],u=[];for(i=0;i<t.length;i++)i%n==0&&u.length&&(e.push(u),u=[]),u.push(t[i]);if(u.length){if(r)for(i=u.length;i<n;i++)u.push(r);e.push(u)}return e},n.capitalize=f,n.center=function(t,n){if(t=u(t,""),n=n||80,t.length>=n)return t;var r=n-t.length,o=i.repeat(" ",r/2-r%2),f=i.repeat(" ",r/2);return e.copySafeness(t,o+t+f)},n.default=function(t,n,r){return r?t||n:void 0!==t?t:n},n.dictsort=function(t,n,r){if(!i.isObject(t))throw new i.TemplateError("dictsort filter: val must be an object");var e,u=[];for(var o in t)u.push([o,t[o]]);if(void 0===r||"key"===r)e=0;else{if("value"!==r)throw new i.TemplateError("dictsort filter: You can only sort by either key or value");e=1}return u.sort(function(t,r){var u=t[e],o=r[e];return n||(i.isString(u)&&(u=u.toUpperCase()),i.isString(o)&&(o=o.toUpperCase())),u>o?1:u===o?0:-1}),u},n.dump=function(t,n){return JSON.stringify(t,null,n)},n.escape=function(t){return t instanceof e.SafeString?t:(t=null===t||void 0===t?"":t,e.markSafe(i.escape(t.toString())))},n.safe=function(t){return t instanceof e.SafeString?t:(t=null===t||void 0===t?"":t,e.markSafe(t.toString()))},n.first=function(t){return t[0]},n.forceescape=function(t){return t=null===t||void 0===t?"":t,e.markSafe(i.escape(t.toString()))},n.groupby=function(t,n){return i.groupBy(t,n,this.env.opts.throwOnUndefined)},n.indent=function(t,n,r){if(""===(t=u(t,"")))return"";n=n||4;var o=t.split("\n"),f=i.repeat(" ",n),c=o.map(function(t,n){return 0!==n||r?""+f+t:t}).join("\n");return e.copySafeness(t,c)},n.join=function(t,n,r){return n=n||"",r&&(t=i.map(t,function(t){return t[r]})),t.join(n)},n.last=function(t){return t[t.length-1]},n.length=function(t){var n=u(t,"");return void 0!==n?"function"==typeof Map&&n instanceof Map||"function"==typeof Set&&n instanceof Set?n.size:!i.isObject(n)||n instanceof e.SafeString?n.length:i.keys(n).length:0},n.list=c,n.lower=function(t){return(t=u(t,"")).toLowerCase()},n.nl2br=function(t){return null===t||void 0===t?"":e.copySafeness(t,t.replace(/\r\n|\n/g,"<br />\n"))},n.random=function(t){return t[Math.floor(Math.random()*t.length)]},n.reject=s(!1),n.rejectattr=function(t,n){return t.filter(function(t){return!t[n]})},n.select=s(!0),n.selectattr=function(t,n){return t.filter(function(t){return!!t[n]})},n.replace=function(t,n,r,i){var u=t;if(n instanceof RegExp)return t.replace(n,r);void 0===i&&(i=-1);var o="";if("number"==typeof n)n=""+n;else if("string"!=typeof n)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof e.SafeString))return t;if(""===n)return o=r+t.split("").join(r)+r,e.copySafeness(t,o);var f=t.indexOf(n);if(0===i||-1===f)return t;for(var c=0,s=0;f>-1&&(-1===i||s<i);)o+=t.substring(c,f)+r,c=f+n.length,s++,f=t.indexOf(n,c);return c<t.length&&(o+=t.substring(c)),e.copySafeness(u,o)},n.reverse=function(t){var n;return(n=i.isString(t)?c(t):i.map(t,function(t){return t})).reverse(),i.isString(t)?e.copySafeness(t,n.join("")):n},n.round=function(t,n,r){var i=Math.pow(10,n=n||0);return("ceil"===r?Math.ceil:"floor"===r?Math.floor:Math.round)(t*i)/i},n.slice=function(t,n,r){for(var i=Math.floor(t.length/n),e=t.length%n,u=[],o=0,f=0;f<n;f++){var c=o+f*i;f<e&&o++;var s=o+(f+1)*i,a=t.slice(c,s);r&&f>=e&&a.push(r),u.push(a)}return u},n.sum=function(t,n,r){return void 0===r&&(r=0),n&&(t=i.map(t,function(t){return t[n]})),r+t.reduce(function(t,n){return t+n},0)},n.sort=e.makeMacro(["value","reverse","case_sensitive","attribute"],[],function(t,n,r,e){var u=this,o=i.map(t,function(t){return t}),f=i.getAttrGetter(e);return o.sort(function(t,o){var c=e?f(t):t,s=e?f(o):o;if(u.env.opts.throwOnUndefined&&e&&(void 0===c||void 0===s))throw new TypeError('sort: attribute "'+e+'" resolved to undefined');return!r&&i.isString(c)&&i.isString(s)&&(c=c.toLowerCase(),s=s.toLowerCase()),c<s?n?1:-1:c>s?n?-1:1:0}),o}),n.string=function(t){return e.copySafeness(t,t)},n.striptags=function(t,n){var r=a((t=u(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|<!--[\s\S]*?-->/gi,"")),i="";return i=n?r.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):r.replace(/\s+/gi," "),e.copySafeness(t,i)},n.title=function(t){var n=(t=u(t,"")).split(" ").map(function(t){return f(t)});return e.copySafeness(t,n.join(" "))},n.trim=a,n.truncate=function(t,n,r,i){var o=t;if(t=u(t,""),n=n||255,t.length<=n)return t;if(r)t=t.substring(0,n);else{var f=t.lastIndexOf(" ",n);-1===f&&(f=n),t=t.substring(0,f)}return t+=void 0!==i&&null!==i?i:"...",e.copySafeness(o,t)},n.upper=function(t){return(t=u(t,"")).toUpperCase()},n.urlencode=function(t){var n=encodeURIComponent;return i.isString(t)?n(t):(i.isArray(t)?t:i.r(t)).map(function(t){var r=t[0],i=t[1];return n(r)+"="+n(i)}).join("&")};var h=/^(?:\(|<|&lt;)?(.*?)(?:\.|,|\)|\n|&gt;)?$/,v=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,l=/^https?:\/\/.*$/,d=/^www\./,p=/\.(?:org|net|com)(?:\:|\/|$)/;n.urlize=function(t,n,r){o(n)&&(n=1/0);var i=!0===r?' rel="nofollow"':"";return t.split(/(\s+)/).filter(function(t){return t&&t.length}).map(function(t){var r=t.match(h),e=r?r[1]:t,u=e.substr(0,n);return l.test(e)?'<a href="'+e+'"'+i+">"+u+"</a>":d.test(e)?'<a href="http://'+e+'"'+i+">"+u+"</a>":v.test(e)?'<a href="mailto:'+e+'">'+e+"</a>":p.test(e)?'<a href="http://'+e+'"'+i+">"+u+"</a>":t}).join("")},n.wordcount=function(t){var n=(t=u(t,""))?t.match(/\w+/g):null;return n?n.length:null},n.float=function(t,n){var r=parseFloat(t);return o(r)?n:r};var y=e.makeMacro(["value","default","base"],[],function(t,n,r){void 0===r&&(r=10);var i=parseInt(t,r);return o(i)?n:i});n.int=y,n.d=n.default,n.e=n.escape},function(t,n,r){"use strict";var i,e="object"==typeof Reflect?Reflect:null,u=e&&"function"==typeof e.apply?e.apply:function(t,n,r){return Function.prototype.apply.call(t,n,r)};i=e&&"function"==typeof e.ownKeys?e.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var o=Number.isNaN||function(t){return t!=t};function f(){f.init.call(this)}t.exports=f,t.exports.once=function(t,n){return new Promise(function(r,i){function e(){void 0!==u&&t.removeListener("error",u),r([].slice.call(arguments))}var u;"error"!==n&&(u=function(r){t.removeListener(n,e),i(r)},t.once("error",u)),t.once(n,e)})},f.EventEmitter=f,f.prototype.y=void 0,f.prototype.b=0,f.prototype.w=void 0;var c=10;function s(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function a(t){return void 0===t.w?f.defaultMaxListeners:t.w}function h(t,n,r,i){var e,u,o;if(s(r),void 0===(u=t.y)?(u=t.y=Object.create(null),t.b=0):(void 0!==u.newListener&&(t.emit("newListener",n,r.listener?r.listener:r),u=t.y),o=u[n]),void 0===o)o=u[n]=r,++t.b;else if("function"==typeof o?o=u[n]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(e=a(t))>0&&o.length>e&&!o.warned){o.warned=!0;var f=Error("Possible EventEmitter memory leak detected. "+o.length+" "+n+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=t,f.type=n,f.count=o.length,console&&console.warn&&console.warn(f)}return t}function v(t,n,r){var i={fired:!1,wrapFn:void 0,target:t,type:n,listener:r},e=function(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}.bind(i);return e.listener=r,i.wrapFn=e,e}function l(t,n,r){var i=t.y;if(void 0===i)return[];var e=i[n];return void 0===e?[]:"function"==typeof e?r?[e.listener||e]:[e]:r?function(t){for(var n=Array(t.length),r=0;r<n.length;++r)n[r]=t[r].listener||t[r];return n}(e):p(e,e.length)}function d(t){var n=this.y;if(void 0!==n){var r=n[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(t,n){for(var r=Array(n),i=0;i<n;++i)r[i]=t[i];return r}Object.defineProperty(f,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(t){if("number"!=typeof t||t<0||o(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");c=t}}),f.init=function(){void 0!==this.y&&this.y!==Object.getPrototypeOf(this).y||(this.y=Object.create(null),this.b=0),this.w=this.w||void 0},f.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||o(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this.w=t,this},f.prototype.getMaxListeners=function(){return a(this)},f.prototype.emit=function(t){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);var i="error"===t,e=this.y;if(void 0!==e)i=i&&void 0===e.error;else if(!i)return!1;if(i){var o;if(n.length>0&&(o=n[0]),o instanceof Error)throw o;var f=Error("Unhandled error."+(o?" ("+o.message+")":""));throw f.context=o,f}var c=e[t];if(void 0===c)return!1;if("function"==typeof c)u(c,this,n);else{var s=c.length,a=p(c,s);for(r=0;r<s;++r)u(a[r],this,n)}return!0},f.prototype.addListener=function(t,n){return h(this,t,n,!1)},f.prototype.on=f.prototype.addListener,f.prototype.prependListener=function(t,n){return h(this,t,n,!0)},f.prototype.once=function(t,n){return s(n),this.on(t,v(this,t,n)),this},f.prototype.prependOnceListener=function(t,n){return s(n),this.prependListener(t,v(this,t,n)),this},f.prototype.removeListener=function(t,n){var r,i,e,u,o;if(s(n),void 0===(i=this.y))return this;if(void 0===(r=i[t]))return this;if(r===n||r.listener===n)0==--this.b?this.y=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,r.listener||n));else if("function"!=typeof r){for(e=-1,u=r.length-1;u>=0;u--)if(r[u]===n||r[u].listener===n){o=r[u].listener,e=u;break}if(e<0)return this;0===e?r.shift():function(t,n){for(;n+1<t.length;n++)t[n]=t[n+1];t.pop()}(r,e),1===r.length&&(i[t]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",t,o||n)}return this},f.prototype.off=f.prototype.removeListener,f.prototype.removeAllListeners=function(t){var n,r,i;if(void 0===(r=this.y))return this;if(void 0===r.removeListener)return 0===arguments.length?(this.y=Object.create(null),this.b=0):void 0!==r[t]&&(0==--this.b?this.y=Object.create(null):delete r[t]),this;if(0===arguments.length){var e,u=Object.keys(r);for(i=0;i<u.length;++i)"removeListener"!==(e=u[i])&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this.y=Object.create(null),this.b=0,this}if("function"==typeof(n=r[t]))this.removeListener(t,n);else if(void 0!==n)for(i=n.length-1;i>=0;i--)this.removeListener(t,n[i]);return this},f.prototype.listeners=function(t){return l(this,t,!0)},f.prototype.rawListeners=function(t){return l(this,t,!1)},f.listenerCount=function(t,n){return"function"==typeof t.listenerCount?t.listenerCount(n):d.call(t,n)},f.prototype.listenerCount=d,f.prototype.eventNames=function(){return this.b>0?i(this.y):[]}},function(t,n,r){"use strict";var i=r(2).SafeString;n.callable=function(t){return"function"==typeof t},n.defined=function(t){return void 0!==t},n.divisibleby=function(t,n){return t%n==0},n.escaped=function(t){return t instanceof i},n.equalto=function(t,n){return t===n},n.eq=n.equalto,n.sameas=n.equalto,n.even=function(t){return t%2==0},n.falsy=function(t){return!t},n.ge=function(t,n){return t>=n},n.greaterthan=function(t,n){return t>n},n.gt=n.greaterthan,n.le=function(t,n){return t<=n},n.lessthan=function(t,n){return t<n},n.lt=n.lessthan,n.lower=function(t){return t.toLowerCase()===t},n.ne=function(t,n){return t!==n},n.null=function(t){return null===t},n.number=function(t){return"number"==typeof t},n.odd=function(t){return t%2==1},n.string=function(t){return"string"==typeof t},n.truthy=function(t){return!!t},n.undefined=function(t){return void 0===t},n.upper=function(t){return t.toUpperCase()===t},n.iterable=function(t){return"undefined"!=typeof Symbol?!!t[Symbol.iterator]:Array.isArray(t)||"string"==typeof t},n.mapping=function(t){var n=null!==t&&void 0!==t&&"object"==typeof t&&!Array.isArray(t);return Set?n&&!(t instanceof Set):n}},function(t,n,r){"use strict";t.exports=function(){return{range:function(t,n,r){void 0===n?(n=t,t=0,r=1):r||(r=1);var i=[];if(r>0)for(var e=t;e<n;e+=r)i.push(e);else for(var u=t;u>n;u+=r)i.push(u);return i},cycler:function(){return t=Array.prototype.slice.call(arguments),n=-1,{current:null,reset:function(){n=-1,this.current=null},next:function(){return++n>=t.length&&(n=0),this.current=t[n],this.current}};var t,n},joiner:function(t){return function(t){t=t||",";var n=!0;return function(){var r=n?"":t;return n=!1,r}}(t)}}}},function(t,n,r){var i=r(0);t.exports=function(t,n){function r(t,n){if(this.name=t,this.path=t,this.defaultEngine=n.defaultEngine,this.ext=i.extname(t),!this.ext&&!this.defaultEngine)throw Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return r.prototype.render=function(n,r){t.render(this.name,n,r)},n.set("view",r),n.set("nunjucksEnv",t),t}},function(t,n,r){t.exports=function(){"use strict";var t,n,r=this.runtime,i=this.lib,e=this.compiler.Compiler,u=this.parser.Parser,o=(this.nodes,this.lexer,r.contextOrFrameLookup),f=r.memberLookup;function c(t,n){return Object.prototype.hasOwnProperty.call(t,n)}e&&(t=e.prototype.assertType),u&&(n=u.prototype.parseAggregate),r.contextOrFrameLookup=function(t,n,r){var i=o.apply(this,arguments);if(void 0!==i)return i;switch(r){case"True":return!0;case"False":return!1;case"None":return null;default:return}};var s={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var n=0;n<this.length;n++)if(this[n]===t)return this.splice(n,1);throw Error("ValueError")},count:function(t){for(var n=0,r=0;r<this.length;r++)this[r]===t&&n++;return n},index:function(t){var n;if(-1===(n=this.indexOf(t)))throw Error("ValueError");return n},find:function(t){return this.indexOf(t)},insert:function(t,n){return this.splice(t,0,n)}},a={items:function(){return i.r(this)},values:function(){return i.u(this)},keys:function(){return i.keys(this)},get:function(t,n){var r=this[t];return void 0===r&&(r=n),r},has_key:function(t){return c(this,t)},pop:function(t,n){var r=this[t];if(void 0===r&&void 0!==n)r=n;else{if(void 0===r)throw Error("KeyError");delete this[t]}return r},popitem:function(){var t=i.keys(this);if(!t.length)throw Error("KeyError");var n=t[0],r=this[n];return delete this[n],[n,r]},setdefault:function(t,n){return void 0===n&&(n=null),t in this||(this[t]=n),this[t]},update:function(t){return i.f(this,t),null}};return a.iteritems=a.items,a.itervalues=a.values,a.iterkeys=a.keys,r.memberLookup=function(t,n,e){return 4===arguments.length?function(t,n,i,e){t=t||[],null===n&&(n=e<0?t.length-1:0),null===i?i=e<0?-1:t.length:i<0&&(i+=t.length),n<0&&(n+=t.length);for(var u=[],o=n;!(o<0||o>t.length||e>0&&o>=i||e<0&&o<=i);o+=e)u.push(r.memberLookup(t,o));return u}.apply(this,arguments):(t=t||{},i.isArray(t)&&c(s,n)?s[n].bind(t):i.isObject(t)&&c(a,n)?a[n].bind(t):f.apply(this,arguments))},function(){r.contextOrFrameLookup=o,r.memberLookup=f,e&&(e.prototype.assertType=t),u&&(u.prototype.parseAggregate=n)}}}])});
/*! Browser bundle of nunjucks 3.2.4 (slim, only works with precompiled templates) */
!function(t,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.nunjucks=n():t.nunjucks=n()}("undefined"!=typeof self?self:this,function(){return function(t){var n={};function r(i){if(n[i])return n[i].exports;var e=n[i]={i:i,l:!1,exports:{}};return t[i].call(e.exports,e,e.exports,r),e.l=!0,e.exports}return r.m=t,r.c=n,r.d=function(t,n,i){r.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:i})},r.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(n,"a",n),n},r.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},r.p="",r(r.s=6)}([function(t,n){},function(t,n,r){"use strict";var i=Array.prototype,e=Object.prototype,u={"&":"&amp;",'"':"&quot;","'":"&#39;","<":"&lt;",">":"&gt;","\\":"&#92;"},o=/[&"'<>\\]/g;function f(t,n){return e.hasOwnProperty.call(t,n)}function c(t){return u[t]}function s(t,n,r){var i,e,u;if(t instanceof Error&&(t=(e=t).name+": "+e.message),Object.setPrototypeOf?Object.setPrototypeOf(i=Error(t),s.prototype):Object.defineProperty(i=this,"message",{enumerable:!1,writable:!0,value:t}),Object.defineProperty(i,"name",{value:"Template render error"}),Error.captureStackTrace&&Error.captureStackTrace(i,this.constructor),e){var o=Object.getOwnPropertyDescriptor(e,"stack");(u=o&&(o.get||function(){return o.value}))||(u=function(){return e.stack})}else{var f=Error(t).stack;u=function(){return f}}return Object.defineProperty(i,"stack",{get:function(){return u.call(i)}}),Object.defineProperty(i,"cause",{value:e}),i.lineno=n,i.colno=r,i.firstUpdate=!0,i.Update=function(t){var n="("+(t||"unknown path")+")";return this.firstUpdate&&(this.lineno&&this.colno?n+=" [Line "+this.lineno+", Column "+this.colno+"]":this.lineno&&(n+=" [Line "+this.lineno+"]")),n+="\n ",this.firstUpdate&&(n+=" "),this.message=n+(this.message||""),this.firstUpdate=!1,this},i}function a(t){return"[object Function]"===e.toString.call(t)}function h(t){return"[object Array]"===e.toString.call(t)}function v(t){return"[object String]"===e.toString.call(t)}function l(t){return"[object Object]"===e.toString.call(t)}function d(t){var n,r=(n=t)?"string"==typeof n?n.split("."):[n]:[];return function(t){for(var n=t,i=0;i<r.length;i++){var e=r[i];if(!f(n,e))return;n=n[e]}return n}}function p(t){return Array.prototype.slice.call(t)}function y(t,n,r){return Array.prototype.indexOf.call(t||[],n,r)}function b(t){var n=[];for(var r in t)f(t,r)&&n.push(r);return n}(n=t.exports={}).hasOwnProp=f,n.t=function(t,r,i){if(i.Update||(i=new n.TemplateError(i)),i.Update(t),!r){var e=i;(i=Error(e.message)).name=e.name}return i},Object.setPrototypeOf?Object.setPrototypeOf(s.prototype,Error.prototype):s.prototype=Object.create(Error.prototype,{constructor:{value:s}}),n.TemplateError=s,n.escape=function(t){return t.replace(o,c)},n.isFunction=a,n.isArray=h,n.isString=v,n.isObject=l,n.getAttrGetter=d,n.groupBy=function(t,n,r){for(var i={},e=a(n)?n:d(n),u=0;u<t.length;u++){var o=t[u],f=e(o,u);if(void 0===f&&!0===r)throw new TypeError('groupby: attribute "'+n+'" resolved to undefined');(i[f]||(i[f]=[])).push(o)}return i},n.toArray=p,n.without=function(t){var n=[];if(!t)return n;for(var r=t.length,i=p(arguments).slice(1),e=-1;++e<r;)-1===y(i,t[e])&&n.push(t[e]);return n},n.repeat=function(t,n){for(var r="",i=0;i<n;i++)r+=t;return r},n.each=function(t,n,r){if(null!=t)if(i.forEach&&t.forEach===i.forEach)t.forEach(n,r);else if(t.length===+t.length)for(var e=0,u=t.length;e<u;e++)n.call(r,t[e],e,t)},n.map=function(t,n){var r=[];if(null==t)return r;if(i.map&&t.map===i.map)return t.map(n);for(var e=0;e<t.length;e++)r[r.length]=n(t[e],e);return t.length===+t.length&&(r.length=t.length),r},n.asyncIter=function(t,n,r){var i=-1;!function e(){++i<t.length?n(t[i],i,e,r):r()}()},n.asyncFor=function(t,n,r){var i=b(t||{}),e=i.length,u=-1;!function o(){var f=i[++u];u<e?n(f,t[f],u,e,o):r()}()},n.indexOf=y,n.keys=b,n.r=function(t){return b(t).map(function(n){return[n,t[n]]})},n.u=function(t){return b(t).map(function(n){return t[n]})},n.f=n.extend=function(t,n){return t=t||{},b(n).forEach(function(r){t[r]=n[r]}),t},n.inOperator=function(t,n){if(h(n)||v(n))return-1!==n.indexOf(t);if(l(n))return t in n;throw Error('Cannot use "in" operator to search for "'+t+'" in unexpected types.')}},function(t,n,r){"use strict";var i=r(1),e=Array.from,u="function"==typeof Symbol&&Symbol.iterator&&"function"==typeof e,o=function(){function t(t,n){this.variables=Object.create(null),this.parent=t,this.topLevel=!1,this.isolateWrites=n}var n=t.prototype;return n.set=function(t,n,r){var i=t.split("."),e=this.variables,u=this;if(r&&(u=this.resolve(i[0],!0)))u.set(t,n);else{for(var o=0;o<i.length-1;o++){var f=i[o];e[f]||(e[f]={}),e=e[f]}e[i[i.length-1]]=n}},n.get=function(t){var n=this.variables[t];return void 0!==n?n:null},n.lookup=function(t){var n=this.parent,r=this.variables[t];return void 0!==r?r:n&&n.lookup(t)},n.resolve=function(t,n){var r=n&&this.isolateWrites?void 0:this.parent;return void 0!==this.variables[t]?this:r&&r.resolve(t)},n.push=function(n){return new t(this,n)},n.pop=function(){return this.parent},t}();function f(t){return t&&Object.prototype.hasOwnProperty.call(t,"__keywords")}function c(t){var n=t.length;return 0===n?0:f(t[n-1])?n-1:n}function s(t){if("string"!=typeof t)return t;this.val=t,this.length=t.length}s.prototype=Object.create(String.prototype,{length:{writable:!0,configurable:!0,value:0}}),s.prototype.valueOf=function(){return this.val},s.prototype.toString=function(){return this.val},t.exports={Frame:o,makeMacro:function(t,n,r){return function(){for(var i=arguments.length,e=Array(i),u=0;u<i;u++)e[u]=arguments[u];var o,s=c(e),a=function(t){var n=t.length;if(n){var r=t[n-1];if(f(r))return r}return{}}(e);if(s>t.length)o=e.slice(0,t.length),e.slice(o.length,s).forEach(function(t,r){r<n.length&&(a[n[r]]=t)}),o.push(a);else if(s<t.length){o=e.slice(0,s);for(var h=s;h<t.length;h++){var v=t[h];o.push(a[v]),delete a[v]}o.push(a)}else o=e;return r.apply(this,o)}},makeKeywordArgs:function(t){return t.__keywords=!0,t},numArgs:c,suppressValue:function(t,n){return t=void 0!==t&&null!==t?t:"",!n||t instanceof s||(t=i.escape(t.toString())),t},ensureDefined:function(t,n,r){if(null===t||void 0===t)throw new i.TemplateError("attempted to output null or undefined value",n+1,r+1);return t},memberLookup:function(t,n){if(void 0!==t&&null!==t)return"function"==typeof t[n]?function(){for(var r=arguments.length,i=Array(r),e=0;e<r;e++)i[e]=arguments[e];return t[n].apply(t,i)}:t[n]},contextOrFrameLookup:function(t,n,r){var i=n.lookup(r);return void 0!==i?i:t.lookup(r)},callWrap:function(t,n,r,i){if(!t)throw Error("Unable to call `"+n+"`, which is undefined or falsey");if("function"!=typeof t)throw Error("Unable to call `"+n+"`, which is not a function");return t.apply(r,i)},handleError:function(t,n,r){return t.lineno?t:new i.TemplateError(t,n,r)},isArray:i.isArray,keys:i.keys,SafeString:s,copySafeness:function(t,n){return t instanceof s?new s(n):n.toString()},markSafe:function(t){var n=typeof t;return"string"===n?new s(t):"function"!==n?t:function(n){var r=t.apply(this,arguments);return"string"==typeof r?new s(r):r}},asyncEach:function(t,n,r,e){if(i.isArray(t)){var u=t.length;i.asyncIter(t,function(t,i,e){switch(n){case 1:r(t,i,u,e);break;case 2:r(t[0],t[1],i,u,e);break;case 3:r(t[0],t[1],t[2],i,u,e);break;default:t.push(i,u,e),r.apply(this,t)}},e)}else i.asyncFor(t,function(t,n,i,e,u){r(t,n,i,e,u)},e)},asyncAll:function(t,n,r,e){var u,o,f=0;function c(t,n){f++,o[t]=n,f===u&&e(null,o.join(""))}if(i.isArray(t))if(u=t.length,o=Array(u),0===u)e(null,"");else for(var s=0;s<t.length;s++){var a=t[s];switch(n){case 1:r(a,s,u,c);break;case 2:r(a[0],a[1],s,u,c);break;case 3:r(a[0],a[1],a[2],s,u,c);break;default:a.push(s,u,c),r.apply(this,a)}}else{var h=i.keys(t||{});if(u=h.length,o=Array(u),0===u)e(null,"");else for(var v=0;v<h.length;v++){var l=h[v];r(l,t[l],v,u,c)}}},inOperator:i.inOperator,fromIterator:function(t){return"object"!=typeof t||null===t||i.isArray(t)?t:u&&Symbol.iterator in t?e(t):t}}},function(t,n,r){"use strict";function i(t,n){return(i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t})(t,n)}var e=function(t){var n,r;function e(n){var r;return(r=t.call(this)||this).precompiled=n||{},r}return r=t,(n=e).prototype=Object.create(r.prototype),n.prototype.constructor=n,i(n,r),e.prototype.getSource=function(t){return this.precompiled[t]?{src:{type:"code",obj:this.precompiled[t]},path:t}:null},e}(r(4));t.exports={PrecompiledLoader:e}},function(t,n,r){"use strict";function i(t,n){return(i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t})(t,n)}var e=r(0),u=r(5).EmitterObj;t.exports=function(t){var n,r;function u(){return t.apply(this,arguments)||this}r=t,(n=u).prototype=Object.create(r.prototype),n.prototype.constructor=n,i(n,r);var o=u.prototype;return o.resolve=function(t,n){return e.resolve(e.dirname(t),n)},o.isRelative=function(t){return 0===t.indexOf("./")||0===t.indexOf("../")},u}(u)},function(t,n,r){"use strict";function i(t,n){for(var r=0;r<n.length;r++){var i=n[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,(e=i.key,void 0,"symbol"==typeof(u=function(t,n){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,n||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(e,"string"))?u:u+""),i)}var e,u}function e(t,n,r){return n&&i(t.prototype,n),r&&i(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function u(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,o(t,n)}function o(t,n){return(o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t})(t,n)}var f=r(13),c=r(1);function s(t,n,r){r=r||{},c.keys(r).forEach(function(n){var i,e;r[n]=(i=t.prototype[n],e=r[n],"function"!=typeof i||"function"!=typeof e?e:function(){var t=this.parent;this.parent=i;var n=e.apply(this,arguments);return this.parent=t,n})});var i=function(t){function r(){return t.apply(this,arguments)||this}return u(r,t),e(r,[{key:"typename",get:function(){return n}}]),r}(t);return c.f(i.prototype,r),i}var a=function(){function t(){this.init.apply(this,arguments)}return t.prototype.init=function(){},t.extend=function(t,n){return"object"==typeof t&&(n=t,t="anonymous"),s(this,t,n)},e(t,[{key:"typename",get:function(){return this.constructor.name}}]),t}(),h=function(t){function n(){var n,r;return(n=r=t.call(this)||this).init.apply(n,arguments),r}return u(n,t),n.prototype.init=function(){},n.extend=function(t,n){return"object"==typeof t&&(n=t,t="anonymous"),s(this,t,n)},e(n,[{key:"typename",get:function(){return this.constructor.name}}]),n}(f);t.exports={Obj:a,EmitterObj:h}},function(t,n,r){"use strict";var i,e=r(1),u=r(7),o=u.Environment,f=u.Template,c=r(4),s=r(3),a=r(0),h=r(0),v=r(0),l=r(0),d=r(2),p=r(0),y=r(17);function b(t,n){var r;return n=n||{},e.isObject(t)&&(n=t,t=null),s.FileSystemLoader?r=new s.FileSystemLoader(t,{watch:n.watch,noCache:n.noCache}):s.WebLoader&&(r=new s.WebLoader(t,{useCache:n.web&&n.web.useCache,async:n.web&&n.web.async})),i=new o(r,n),n&&n.express&&i.express(n.express),i}t.exports={Environment:o,Template:f,Loader:c,FileSystemLoader:s.FileSystemLoader,NodeResolveLoader:s.NodeResolveLoader,PrecompiledLoader:s.PrecompiledLoader,WebLoader:s.WebLoader,compiler:h,parser:v,lexer:l,runtime:d,lib:e,nodes:p,installJinjaCompat:y,configure:b,reset:function(){i=void 0},compile:function(t,n,r,e){return i||b(),new f(t,n,r,e)},render:function(t,n,r){return i||b(),i.render(t,n,r)},renderString:function(t,n,r){return i||b(),i.renderString(t,n,r)},precompile:a?a.precompile:void 0,precompileString:a?a.precompileString:void 0}},function(t,n,r){"use strict";function i(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,e(t,n)}function e(t,n){return(e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t})(t,n)}var u=r(8),o=r(11),f=r(1),c=r(0),s=r(12),a=r(3),h=a.FileSystemLoader,v=a.WebLoader,l=a.PrecompiledLoader,d=r(14),p=r(15),y=r(5),b=y.Obj,w=y.EmitterObj,m=r(2),j=m.handleError,g=m.Frame,E=r(16);function O(t,n,r){u(function(){t(n,r)})}var k={type:"code",obj:{root:function(t,n,r,i,e){try{e(null,"")}catch(t){e(j(t,null,null))}}}},A=function(t){function n(){return t.apply(this,arguments)||this}i(n,t);var r=n.prototype;return r.init=function(t,n){var r=this;n=this.opts=n||{},this.opts.dev=!!n.dev,this.opts.autoescape=null==n.autoescape||n.autoescape,this.opts.throwOnUndefined=!!n.throwOnUndefined,this.opts.trimBlocks=!!n.trimBlocks,this.opts.lstripBlocks=!!n.lstripBlocks,this.loaders=[],t?this.loaders=f.isArray(t)?t:[t]:h?this.loaders=[new h("views")]:v&&(this.loaders=[new v("/views")]),"undefined"!=typeof window&&window.nunjucksPrecompiled&&this.loaders.unshift(new l(window.nunjucksPrecompiled)),this.a(),this.globals=p(),this.filters={},this.tests={},this.asyncFilters=[],this.extensions={},this.extensionsList=[],f.r(s).forEach(function(t){var n=t[0],i=t[1];return r.addFilter(n,i)}),f.r(d).forEach(function(t){var n=t[0],i=t[1];return r.addTest(n,i)})},r.a=function(){var t=this;this.loaders.forEach(function(n){n.cache={},"function"==typeof n.on&&(n.on("update",function(r,i){n.cache[r]=null,t.emit("update",r,i,n)}),n.on("load",function(r,i){t.emit("load",r,i,n)}))})},r.invalidateCache=function(){this.loaders.forEach(function(t){t.cache={}})},r.addExtension=function(t,n){return n.__name=t,this.extensions[t]=n,this.extensionsList.push(n),this},r.removeExtension=function(t){var n=this.getExtension(t);n&&(this.extensionsList=f.without(this.extensionsList,n),delete this.extensions[t])},r.getExtension=function(t){return this.extensions[t]},r.hasExtension=function(t){return!!this.extensions[t]},r.addGlobal=function(t,n){return this.globals[t]=n,this},r.getGlobal=function(t){if(void 0===this.globals[t])throw Error("global not found: "+t);return this.globals[t]},r.addFilter=function(t,n,r){var i=n;return r&&this.asyncFilters.push(t),this.filters[t]=i,this},r.getFilter=function(t){if(!this.filters[t])throw Error("filter not found: "+t);return this.filters[t]},r.addTest=function(t,n){return this.tests[t]=n,this},r.getTest=function(t){if(!this.tests[t])throw Error("test not found: "+t);return this.tests[t]},r.resolveTemplate=function(t,n,r){return!(!t.isRelative||!n)&&t.isRelative(r)&&t.resolve?t.resolve(n,r):r},r.getTemplate=function(t,n,r,i,e){var u,o=this,c=this,s=null;if(t&&t.raw&&(t=t.raw),f.isFunction(r)&&(e=r,r=null,n=n||!1),f.isFunction(n)&&(e=n,n=!1),t instanceof L)s=t;else{if("string"!=typeof t)throw Error("template names must be a string: "+t);for(var a=0;a<this.loaders.length;a++){var h=this.loaders[a];if(s=h.cache[this.resolveTemplate(h,r,t)])break}}if(s)return n&&s.compile(),e?void e(null,s):s;return f.asyncIter(this.loaders,function(n,i,e,u){function o(t,r){t?u(t):r?(r.loader=n,u(null,r)):e()}t=c.resolveTemplate(n,r,t),n.async?n.getSource(t,o):o(null,n.getSource(t))},function(r,f){if(f||r||i||(r=Error("template not found: "+t)),r){if(e)return void e(r);throw r}var c;f?(c=new L(f.src,o,f.path,n),f.noCache||(f.loader.cache[t]=c)):c=new L(k,o,"",n),e?e(null,c):u=c}),u},r.express=function(t){return E(this,t)},r.render=function(t,n,r){f.isFunction(n)&&(r=n,n=null);var i=null;return this.getTemplate(t,function(t,e){if(t&&r)O(r,t);else{if(t)throw t;i=e.render(n,r)}}),i},r.renderString=function(t,n,r,i){return f.isFunction(r)&&(i=r,r={}),new L(t,this,(r=r||{}).path).render(n,i)},r.waterfall=function(t,n,r){return o(t,n,r)},n}(w),S=function(t){function n(){return t.apply(this,arguments)||this}i(n,t);var r=n.prototype;return r.init=function(t,n,r){var i=this;this.env=r||new A,this.ctx=f.extend({},t),this.blocks={},this.exported=[],f.keys(n).forEach(function(t){i.addBlock(t,n[t])})},r.lookup=function(t){return t in this.env.globals&&!(t in this.ctx)?this.env.globals[t]:this.ctx[t]},r.setVariable=function(t,n){this.ctx[t]=n},r.getVariables=function(){return this.ctx},r.addBlock=function(t,n){return this.blocks[t]=this.blocks[t]||[],this.blocks[t].push(n),this},r.getBlock=function(t){if(!this.blocks[t])throw Error('unknown block "'+t+'"');return this.blocks[t][0]},r.getSuper=function(t,n,r,i,e,u){var o=f.indexOf(this.blocks[n]||[],r),c=this.blocks[n][o+1];if(-1===o||!c)throw Error('no super block available for "'+n+'"');c(t,this,i,e,u)},r.addExport=function(t){this.exported.push(t)},r.getExported=function(){var t=this,n={};return this.exported.forEach(function(r){n[r]=t.ctx[r]}),n},n}(b),L=function(t){function n(){return t.apply(this,arguments)||this}i(n,t);var r=n.prototype;return r.init=function(t,n,r,i){if(this.env=n||new A,f.isObject(t))switch(t.type){case"code":this.tmplProps=t.obj;break;case"string":this.tmplStr=t.obj;break;default:throw Error("Unexpected template object type "+t.type+"; expected 'code', or 'string'")}else{if(!f.isString(t))throw Error("src must be a string or an object describing the source");this.tmplStr=t}if(this.path=r,i)try{this.h()}catch(t){throw f.t(this.path,this.env.opts.dev,t)}else this.compiled=!1},r.render=function(t,n,r){var i=this;"function"==typeof t?(r=t,t={}):"function"==typeof n&&(r=n,n=null);var e=!n;try{this.compile()}catch(t){var u=f.t(this.path,this.env.opts.dev,t);if(r)return O(r,u);throw u}var o=new S(t||{},this.blocks,this.env),c=n?n.push(!0):new g;c.topLevel=!0;var s=null,a=!1;return this.rootRenderFunc(this.env,o,c,m,function(t,n){if(!a||!r||void 0===n)if(t&&(t=f.t(i.path,i.env.opts.dev,t),a=!0),r)e?O(r,t,n):r(t,n);else{if(t)throw t;s=n}}),s},r.getExported=function(t,n,r){"function"==typeof t&&(r=t,t={}),"function"==typeof n&&(r=n,n=null);try{this.compile()}catch(t){if(r)return r(t);throw t}var i=n?n.push():new g;i.topLevel=!0;var e=new S(t||{},this.blocks,this.env);this.rootRenderFunc(this.env,e,i,m,function(t){t?r(t,null):r(null,e.getExported())})},r.compile=function(){this.compiled||this.h()},r.h=function(){var t;if(this.tmplProps)t=this.tmplProps;else{var n=c.compile(this.tmplStr,this.env.asyncFilters,this.env.extensionsList,this.path,this.env.opts);t=Function(n)()}this.blocks=this.v(t),this.rootRenderFunc=t.root,this.compiled=!0},r.v=function(t){var n={};return f.keys(t).forEach(function(r){"b_"===r.slice(0,2)&&(n[r.slice(2)]=t[r])}),n},n}(b);t.exports={Environment:A,Template:L}},function(t,n,r){"use strict";var i=r(9),e=[],u=[],o=i.makeRequestCallFromTimer(function(){if(u.length)throw u.shift()});function f(t){var n;(n=e.length?e.pop():new c).task=t,i(n)}function c(){this.task=null}t.exports=f,c.prototype.call=function(){try{this.task.call()}catch(t){f.onerror?f.onerror(t):(u.push(t),o())}finally{this.task=null,e[e.length]=this}}},function(t,n,r){"use strict";!function(n){function r(t){e.length||(i(),!0),e[e.length]=t}t.exports=r;var i,e=[],u=0,o=1024;function f(){for(;u<e.length;){var t=u;if(u+=1,e[t].call(),u>o){for(var n=0,r=e.length-u;n<r;n++)e[n]=e[n+u];e.length-=u,u=0}}e.length=0,u=0,!1}var c,s,a,h=void 0!==n?n:self,v=h.MutationObserver||h.WebKitMutationObserver;function l(t){return function(){var n=setTimeout(i,0),r=setInterval(i,50);function i(){clearTimeout(n),clearInterval(r),t()}}}"function"==typeof v?(c=1,s=new v(f),a=document.createTextNode(""),s.observe(a,{characterData:!0}),i=function(){c=-c,a.data=c}):i=l(f),r.requestFlush=i,r.makeRequestCallFromTimer=l}(r(10))},function(t,n){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,n,r){var i;!function(r){"use strict";var e=function(){var t=Array.prototype.slice.call(arguments);"function"==typeof t[0]&&t[0].apply(null,t.splice(1))},u=function(t){"function"==typeof setImmediate?setImmediate(t):"undefined"!=typeof process&&process.nextTick?process.nextTick(t):setTimeout(t,0)},o=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},f=function(t,n,r){var i=r?u:e;if(n=n||function(){},!o(t))return n(Error("First argument to waterfall must be an array of functions"));if(!t.length)return n();var f=function(t){return function(r){if(r)n.apply(null,arguments),n=function(){};else{var e=Array.prototype.slice.call(arguments,1),u=t.next();u?e.push(f(u)):e.push(n),i(function(){t.apply(null,e)})}}};f(function(t){var n=function(r){var i=function(){return t.length&&t[r].apply(null,arguments),i.next()};return i.next=function(){return r<t.length-1?n(r+1):null},i};return n(0)}(t))()};void 0===(i=function(){return f}.apply(n,[]))||(t.exports=i)}()},function(t,n,r){"use strict";var i=r(1),e=r(2);function u(t,n){return null===t||void 0===t||!1===t?n:t}function o(t){return t!=t}function f(t){var n=(t=u(t,"")).toLowerCase();return e.copySafeness(t,n.charAt(0).toUpperCase()+n.slice(1))}function c(t){if(i.isString(t))return t.split("");if(i.isObject(t))return i.r(t||{}).map(function(t){return{key:t[0],value:t[1]}});if(i.isArray(t))return t;throw new i.TemplateError("list filter: type not iterable")}function s(t){return function(n,r,e){void 0===r&&(r="truthy");var u=this,o=u.env.getTest(r);return i.toArray(n).filter(function(n){return o.call(u,n,e)===t})}}function a(t){return e.copySafeness(t,t.replace(/^\s*|\s*$/g,""))}(n=t.exports={}).abs=Math.abs,n.batch=function(t,n,r){var i,e=[],u=[];for(i=0;i<t.length;i++)i%n==0&&u.length&&(e.push(u),u=[]),u.push(t[i]);if(u.length){if(r)for(i=u.length;i<n;i++)u.push(r);e.push(u)}return e},n.capitalize=f,n.center=function(t,n){if(t=u(t,""),n=n||80,t.length>=n)return t;var r=n-t.length,o=i.repeat(" ",r/2-r%2),f=i.repeat(" ",r/2);return e.copySafeness(t,o+t+f)},n.default=function(t,n,r){return r?t||n:void 0!==t?t:n},n.dictsort=function(t,n,r){if(!i.isObject(t))throw new i.TemplateError("dictsort filter: val must be an object");var e,u=[];for(var o in t)u.push([o,t[o]]);if(void 0===r||"key"===r)e=0;else{if("value"!==r)throw new i.TemplateError("dictsort filter: You can only sort by either key or value");e=1}return u.sort(function(t,r){var u=t[e],o=r[e];return n||(i.isString(u)&&(u=u.toUpperCase()),i.isString(o)&&(o=o.toUpperCase())),u>o?1:u===o?0:-1}),u},n.dump=function(t,n){return JSON.stringify(t,null,n)},n.escape=function(t){return t instanceof e.SafeString?t:(t=null===t||void 0===t?"":t,e.markSafe(i.escape(t.toString())))},n.safe=function(t){return t instanceof e.SafeString?t:(t=null===t||void 0===t?"":t,e.markSafe(t.toString()))},n.first=function(t){return t[0]},n.forceescape=function(t){return t=null===t||void 0===t?"":t,e.markSafe(i.escape(t.toString()))},n.groupby=function(t,n){return i.groupBy(t,n,this.env.opts.throwOnUndefined)},n.indent=function(t,n,r){if(""===(t=u(t,"")))return"";n=n||4;var o=t.split("\n"),f=i.repeat(" ",n),c=o.map(function(t,n){return 0!==n||r?""+f+t:t}).join("\n");return e.copySafeness(t,c)},n.join=function(t,n,r){return n=n||"",r&&(t=i.map(t,function(t){return t[r]})),t.join(n)},n.last=function(t){return t[t.length-1]},n.length=function(t){var n=u(t,"");return void 0!==n?"function"==typeof Map&&n instanceof Map||"function"==typeof Set&&n instanceof Set?n.size:!i.isObject(n)||n instanceof e.SafeString?n.length:i.keys(n).length:0},n.list=c,n.lower=function(t){return(t=u(t,"")).toLowerCase()},n.nl2br=function(t){return null===t||void 0===t?"":e.copySafeness(t,t.replace(/\r\n|\n/g,"<br />\n"))},n.random=function(t){return t[Math.floor(Math.random()*t.length)]},n.reject=s(!1),n.rejectattr=function(t,n){return t.filter(function(t){return!t[n]})},n.select=s(!0),n.selectattr=function(t,n){return t.filter(function(t){return!!t[n]})},n.replace=function(t,n,r,i){var u=t;if(n instanceof RegExp)return t.replace(n,r);void 0===i&&(i=-1);var o="";if("number"==typeof n)n=""+n;else if("string"!=typeof n)return t;if("number"==typeof t&&(t=""+t),"string"!=typeof t&&!(t instanceof e.SafeString))return t;if(""===n)return o=r+t.split("").join(r)+r,e.copySafeness(t,o);var f=t.indexOf(n);if(0===i||-1===f)return t;for(var c=0,s=0;f>-1&&(-1===i||s<i);)o+=t.substring(c,f)+r,c=f+n.length,s++,f=t.indexOf(n,c);return c<t.length&&(o+=t.substring(c)),e.copySafeness(u,o)},n.reverse=function(t){var n;return(n=i.isString(t)?c(t):i.map(t,function(t){return t})).reverse(),i.isString(t)?e.copySafeness(t,n.join("")):n},n.round=function(t,n,r){var i=Math.pow(10,n=n||0);return("ceil"===r?Math.ceil:"floor"===r?Math.floor:Math.round)(t*i)/i},n.slice=function(t,n,r){for(var i=Math.floor(t.length/n),e=t.length%n,u=[],o=0,f=0;f<n;f++){var c=o+f*i;f<e&&o++;var s=o+(f+1)*i,a=t.slice(c,s);r&&f>=e&&a.push(r),u.push(a)}return u},n.sum=function(t,n,r){return void 0===r&&(r=0),n&&(t=i.map(t,function(t){return t[n]})),r+t.reduce(function(t,n){return t+n},0)},n.sort=e.makeMacro(["value","reverse","case_sensitive","attribute"],[],function(t,n,r,e){var u=this,o=i.map(t,function(t){return t}),f=i.getAttrGetter(e);return o.sort(function(t,o){var c=e?f(t):t,s=e?f(o):o;if(u.env.opts.throwOnUndefined&&e&&(void 0===c||void 0===s))throw new TypeError('sort: attribute "'+e+'" resolved to undefined');return!r&&i.isString(c)&&i.isString(s)&&(c=c.toLowerCase(),s=s.toLowerCase()),c<s?n?1:-1:c>s?n?-1:1:0}),o}),n.string=function(t){return e.copySafeness(t,t)},n.striptags=function(t,n){var r=a((t=u(t,"")).replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>|<!--[\s\S]*?-->/gi,"")),i="";return i=n?r.replace(/^ +| +$/gm,"").replace(/ +/g," ").replace(/(\r\n)/g,"\n").replace(/\n\n\n+/g,"\n\n"):r.replace(/\s+/gi," "),e.copySafeness(t,i)},n.title=function(t){var n=(t=u(t,"")).split(" ").map(function(t){return f(t)});return e.copySafeness(t,n.join(" "))},n.trim=a,n.truncate=function(t,n,r,i){var o=t;if(t=u(t,""),n=n||255,t.length<=n)return t;if(r)t=t.substring(0,n);else{var f=t.lastIndexOf(" ",n);-1===f&&(f=n),t=t.substring(0,f)}return t+=void 0!==i&&null!==i?i:"...",e.copySafeness(o,t)},n.upper=function(t){return(t=u(t,"")).toUpperCase()},n.urlencode=function(t){var n=encodeURIComponent;return i.isString(t)?n(t):(i.isArray(t)?t:i.r(t)).map(function(t){var r=t[0],i=t[1];return n(r)+"="+n(i)}).join("&")};var h=/^(?:\(|<|&lt;)?(.*?)(?:\.|,|\)|\n|&gt;)?$/,v=/^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i,l=/^https?:\/\/.*$/,d=/^www\./,p=/\.(?:org|net|com)(?:\:|\/|$)/;n.urlize=function(t,n,r){o(n)&&(n=1/0);var i=!0===r?' rel="nofollow"':"";return t.split(/(\s+)/).filter(function(t){return t&&t.length}).map(function(t){var r=t.match(h),e=r?r[1]:t,u=e.substr(0,n);return l.test(e)?'<a href="'+e+'"'+i+">"+u+"</a>":d.test(e)?'<a href="http://'+e+'"'+i+">"+u+"</a>":v.test(e)?'<a href="mailto:'+e+'">'+e+"</a>":p.test(e)?'<a href="http://'+e+'"'+i+">"+u+"</a>":t}).join("")},n.wordcount=function(t){var n=(t=u(t,""))?t.match(/\w+/g):null;return n?n.length:null},n.float=function(t,n){var r=parseFloat(t);return o(r)?n:r};var y=e.makeMacro(["value","default","base"],[],function(t,n,r){void 0===r&&(r=10);var i=parseInt(t,r);return o(i)?n:i});n.int=y,n.d=n.default,n.e=n.escape},function(t,n,r){"use strict";var i,e="object"==typeof Reflect?Reflect:null,u=e&&"function"==typeof e.apply?e.apply:function(t,n,r){return Function.prototype.apply.call(t,n,r)};i=e&&"function"==typeof e.ownKeys?e.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var o=Number.isNaN||function(t){return t!=t};function f(){f.init.call(this)}t.exports=f,t.exports.once=function(t,n){return new Promise(function(r,i){function e(r){t.removeListener(n,u),i(r)}function u(){"function"==typeof t.removeListener&&t.removeListener("error",e),r([].slice.call(arguments))}y(t,n,u,{once:!0}),"error"!==n&&function(t,n,r){"function"==typeof t.on&&y(t,"error",n,r)}(t,e,{once:!0})})},f.EventEmitter=f,f.prototype.y=void 0,f.prototype.b=0,f.prototype.w=void 0;var c=10;function s(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function a(t){return void 0===t.w?f.defaultMaxListeners:t.w}function h(t,n,r,i){var e,u,o;if(s(r),void 0===(u=t.y)?(u=t.y=Object.create(null),t.b=0):(void 0!==u.newListener&&(t.emit("newListener",n,r.listener?r.listener:r),u=t.y),o=u[n]),void 0===o)o=u[n]=r,++t.b;else if("function"==typeof o?o=u[n]=i?[r,o]:[o,r]:i?o.unshift(r):o.push(r),(e=a(t))>0&&o.length>e&&!o.warned){o.warned=!0;var f=Error("Possible EventEmitter memory leak detected. "+o.length+" "+n+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=t,f.type=n,f.count=o.length,console&&console.warn&&console.warn(f)}return t}function v(t,n,r){var i={fired:!1,wrapFn:void 0,target:t,type:n,listener:r},e=function(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}.bind(i);return e.listener=r,i.wrapFn=e,e}function l(t,n,r){var i=t.y;if(void 0===i)return[];var e=i[n];return void 0===e?[]:"function"==typeof e?r?[e.listener||e]:[e]:r?function(t){for(var n=Array(t.length),r=0;r<n.length;++r)n[r]=t[r].listener||t[r];return n}(e):p(e,e.length)}function d(t){var n=this.y;if(void 0!==n){var r=n[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(t,n){for(var r=Array(n),i=0;i<n;++i)r[i]=t[i];return r}function y(t,n,r,i){if("function"==typeof t.on)i.once?t.once(n,r):t.on(n,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(n,function e(u){i.once&&t.removeEventListener(n,e),r(u)})}}Object.defineProperty(f,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(t){if("number"!=typeof t||t<0||o(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");c=t}}),f.init=function(){void 0!==this.y&&this.y!==Object.getPrototypeOf(this).y||(this.y=Object.create(null),this.b=0),this.w=this.w||void 0},f.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||o(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this.w=t,this},f.prototype.getMaxListeners=function(){return a(this)},f.prototype.emit=function(t){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);var i="error"===t,e=this.y;if(void 0!==e)i=i&&void 0===e.error;else if(!i)return!1;if(i){var o;if(n.length>0&&(o=n[0]),o instanceof Error)throw o;var f=Error("Unhandled error."+(o?" ("+o.message+")":""));throw f.context=o,f}var c=e[t];if(void 0===c)return!1;if("function"==typeof c)u(c,this,n);else{var s=c.length,a=p(c,s);for(r=0;r<s;++r)u(a[r],this,n)}return!0},f.prototype.addListener=function(t,n){return h(this,t,n,!1)},f.prototype.on=f.prototype.addListener,f.prototype.prependListener=function(t,n){return h(this,t,n,!0)},f.prototype.once=function(t,n){return s(n),this.on(t,v(this,t,n)),this},f.prototype.prependOnceListener=function(t,n){return s(n),this.prependListener(t,v(this,t,n)),this},f.prototype.removeListener=function(t,n){var r,i,e,u,o;if(s(n),void 0===(i=this.y))return this;if(void 0===(r=i[t]))return this;if(r===n||r.listener===n)0==--this.b?this.y=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,r.listener||n));else if("function"!=typeof r){for(e=-1,u=r.length-1;u>=0;u--)if(r[u]===n||r[u].listener===n){o=r[u].listener,e=u;break}if(e<0)return this;0===e?r.shift():function(t,n){for(;n+1<t.length;n++)t[n]=t[n+1];t.pop()}(r,e),1===r.length&&(i[t]=r[0]),void 0!==i.removeListener&&this.emit("removeListener",t,o||n)}return this},f.prototype.off=f.prototype.removeListener,f.prototype.removeAllListeners=function(t){var n,r,i;if(void 0===(r=this.y))return this;if(void 0===r.removeListener)return 0===arguments.length?(this.y=Object.create(null),this.b=0):void 0!==r[t]&&(0==--this.b?this.y=Object.create(null):delete r[t]),this;if(0===arguments.length){var e,u=Object.keys(r);for(i=0;i<u.length;++i)"removeListener"!==(e=u[i])&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this.y=Object.create(null),this.b=0,this}if("function"==typeof(n=r[t]))this.removeListener(t,n);else if(void 0!==n)for(i=n.length-1;i>=0;i--)this.removeListener(t,n[i]);return this},f.prototype.listeners=function(t){return l(this,t,!0)},f.prototype.rawListeners=function(t){return l(this,t,!1)},f.listenerCount=function(t,n){return"function"==typeof t.listenerCount?t.listenerCount(n):d.call(t,n)},f.prototype.listenerCount=d,f.prototype.eventNames=function(){return this.b>0?i(this.y):[]}},function(t,n,r){"use strict";var i=r(2).SafeString;n.callable=function(t){return"function"==typeof t},n.defined=function(t){return void 0!==t},n.divisibleby=function(t,n){return t%n==0},n.escaped=function(t){return t instanceof i},n.equalto=function(t,n){return t===n},n.eq=n.equalto,n.sameas=n.equalto,n.even=function(t){return t%2==0},n.falsy=function(t){return!t},n.ge=function(t,n){return t>=n},n.greaterthan=function(t,n){return t>n},n.gt=n.greaterthan,n.le=function(t,n){return t<=n},n.lessthan=function(t,n){return t<n},n.lt=n.lessthan,n.lower=function(t){return t.toLowerCase()===t},n.ne=function(t,n){return t!==n},n.null=function(t){return null===t},n.number=function(t){return"number"==typeof t},n.odd=function(t){return t%2==1},n.string=function(t){return"string"==typeof t},n.truthy=function(t){return!!t},n.undefined=function(t){return void 0===t},n.upper=function(t){return t.toUpperCase()===t},n.iterable=function(t){return"undefined"!=typeof Symbol?!!t[Symbol.iterator]:Array.isArray(t)||"string"==typeof t},n.mapping=function(t){var n=null!==t&&void 0!==t&&"object"==typeof t&&!Array.isArray(t);return Set?n&&!(t instanceof Set):n}},function(t,n,r){"use strict";t.exports=function(){return{range:function(t,n,r){void 0===n?(n=t,t=0,r=1):r||(r=1);var i=[];if(r>0)for(var e=t;e<n;e+=r)i.push(e);else for(var u=t;u>n;u+=r)i.push(u);return i},cycler:function(){return t=Array.prototype.slice.call(arguments),n=-1,{current:null,reset:function(){n=-1,this.current=null},next:function(){return++n>=t.length&&(n=0),this.current=t[n],this.current}};var t,n},joiner:function(t){return function(t){t=t||",";var n=!0;return function(){var r=n?"":t;return n=!1,r}}(t)}}}},function(t,n,r){var i=r(0);t.exports=function(t,n){function r(t,n){if(this.name=t,this.path=t,this.defaultEngine=n.defaultEngine,this.ext=i.extname(t),!this.ext&&!this.defaultEngine)throw Error("No default engine was specified and no extension was provided.");this.ext||(this.name+=this.ext=("."!==this.defaultEngine[0]?".":"")+this.defaultEngine)}return r.prototype.render=function(n,r){t.render(this.name,n,r)},n.set("view",r),n.set("nunjucksEnv",t),t}},function(t,n,r){t.exports=function(){"use strict";var t,n,r=this.runtime,i=this.lib,e=this.compiler.Compiler,u=this.parser.Parser,o=(this.nodes,this.lexer,r.contextOrFrameLookup),f=r.memberLookup;function c(t,n){return Object.prototype.hasOwnProperty.call(t,n)}e&&(t=e.prototype.assertType),u&&(n=u.prototype.parseAggregate),r.contextOrFrameLookup=function(t,n,r){var i=o.apply(this,arguments);if(void 0!==i)return i;switch(r){case"True":return!0;case"False":return!1;case"None":return null;default:return}};var s={pop:function(t){if(void 0===t)return this.pop();if(t>=this.length||t<0)throw Error("KeyError");return this.splice(t,1)},append:function(t){return this.push(t)},remove:function(t){for(var n=0;n<this.length;n++)if(this[n]===t)return this.splice(n,1);throw Error("ValueError")},count:function(t){for(var n=0,r=0;r<this.length;r++)this[r]===t&&n++;return n},index:function(t){var n;if(-1===(n=this.indexOf(t)))throw Error("ValueError");return n},find:function(t){return this.indexOf(t)},insert:function(t,n){return this.splice(t,0,n)}},a={items:function(){return i.r(this)},values:function(){return i.u(this)},keys:function(){return i.keys(this)},get:function(t,n){var r=this[t];return void 0===r&&(r=n),r},has_key:function(t){return c(this,t)},pop:function(t,n){var r=this[t];if(void 0===r&&void 0!==n)r=n;else{if(void 0===r)throw Error("KeyError");delete this[t]}return r},popitem:function(){var t=i.keys(this);if(!t.length)throw Error("KeyError");var n=t[0],r=this[n];return delete this[n],[n,r]},setdefault:function(t,n){return void 0===n&&(n=null),t in this||(this[t]=n),this[t]},update:function(t){return i.f(this,t),null}};return a.iteritems=a.items,a.itervalues=a.values,a.iterkeys=a.keys,r.memberLookup=function(t,n,e){return 4===arguments.length?function(t,n,i,e){t=t||[],null===n&&(n=e<0?t.length-1:0),null===i?i=e<0?-1:t.length:i<0&&(i+=t.length),n<0&&(n+=t.length);for(var u=[],o=n;!(o<0||o>t.length||e>0&&o>=i||e<0&&o<=i);o+=e)u.push(r.memberLookup(t,o));return u}.apply(this,arguments):(t=t||{},i.isArray(t)&&c(s,n)?s[n].bind(t):i.isObject(t)&&c(a,n)?a[n].bind(t):f.apply(this,arguments))},function(){r.contextOrFrameLookup=o,r.memberLookup=f,e&&(e.prototype.assertType=t),u&&(u.prototype.parseAggregate=n)}}}])});
//# sourceMappingURL=nunjucks-slim.min.js.map
'use strict';
var lib = require('./src/lib');
var _require = require('./src/environment'),
Environment = _require.Environment,
Template = _require.Template;
Environment = _require.Environment,
Template = _require.Template;
var Loader = require('./src/loader');
var loaders = require('./src/loaders');
var precompile = require('./src/precompile');
var compiler = require('./src/compiler');
var parser = require('./src/parser');
var lexer = require('./src/lexer');
var runtime = require('./src/runtime');
var nodes = require('./src/nodes');
var installJinjaCompat = require('./src/jinja-compat');
var installJinjaCompat = require('./src/jinja-compat'); // A single instance of an environment, since this is so commonly used
// A single instance of an environment, since this is so commonly used
var e;
function configure(templatesPath, opts) {
opts = opts || {};
if (lib.isObject(templatesPath)) {

@@ -37,5 +25,3 @@ opts = templatesPath;

}
var TemplateLoader;
if (loaders.FileSystemLoader) {

@@ -52,12 +38,8 @@ TemplateLoader = new loaders.FileSystemLoader(templatesPath, {

}
e = new Environment(TemplateLoader, opts);
if (opts && opts.express) {
e.express(opts.express);
}
return e;
}
module.exports = {

@@ -86,3 +68,2 @@ Environment: Environment,

}
return new Template(src, env, path, eagerCompile);

@@ -94,3 +75,2 @@ },

}
return e.render(name, ctx, cb);

@@ -102,3 +82,2 @@ },

}
return e.renderString(src, ctx, cb);

@@ -105,0 +84,0 @@ },

{
"name": "nunjucks",
"description": "A powerful templating engine with inheritance, asynchronous control, and more (jinja2 inspired)",
"version": "3.2.3",
"version": "3.2.4",
"author": "James Long <longster@gmail.com>",

@@ -6,0 +6,0 @@ "dependencies": {

'use strict';
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var parser = require('./parser');
var transformer = require('./transformer');
var nodes = require('./nodes');
var _require = require('./lib'),
TemplateError = _require.TemplateError;
TemplateError = _require.TemplateError;
var _require2 = require('./runtime'),
Frame = _require2.Frame;
Frame = _require2.Frame;
var _require3 = require('./object'),
Obj = _require3.Obj;
var _require3 = require('./object'),
Obj = _require3.Obj; // These are all the same for now, but shouldn't be passed straight
// These are all the same for now, but shouldn't be passed straight
// through
var compareOps = {

@@ -34,12 +27,8 @@ '==': '==',

};
var Compiler = /*#__PURE__*/function (_Obj) {
_inheritsLoose(Compiler, _Obj);
function Compiler() {
return _Obj.apply(this, arguments) || this;
}
var _proto = Compiler.prototype;
_proto.init = function init(templateName, throwOnUndefined) {

@@ -55,3 +44,2 @@ this.templateName = templateName;

};
_proto.fail = function fail(msg, lineno, colno) {

@@ -61,40 +49,28 @@ if (lineno !== undefined) {

}
if (colno !== undefined) {
colno += 1;
}
throw new TemplateError(msg, lineno, colno);
};
_proto._pushBuffer = function _pushBuffer() {
var id = this._tmpid();
this.bufferStack.push(this.buffer);
this.buffer = id;
this._emit("var " + this.buffer + " = \"\";");
return id;
};
_proto._popBuffer = function _popBuffer() {
this.buffer = this.bufferStack.pop();
};
_proto._emit = function _emit(code) {
this.codebuf.push(code);
};
_proto._emitLine = function _emitLine(code) {
this._emit(code + '\n');
};
_proto._emitLines = function _emitLines() {
var _this = this;
for (var _len = arguments.length, lines = new Array(_len), _key = 0; _key < _len; _key++) {
lines[_key] = arguments[_key];
}
lines.forEach(function (line) {

@@ -104,18 +80,11 @@ return _this._emitLine(line);

};
_proto._emitFuncBegin = function _emitFuncBegin(node, name) {
this.buffer = 'output';
this._scopeClosers = '';
this._emitLine("function " + name + "(env, context, frame, runtime, cb) {");
this._emitLine("var lineno = " + node.lineno + ";");
this._emitLine("var colno = " + node.colno + ";");
this._emitLine("var " + this.buffer + " = \"\";");
this._emitLine('try {');
};
_proto._emitFuncEnd = function _emitFuncEnd(noReturn) {

@@ -125,26 +94,16 @@ if (!noReturn) {

}
this._closeScopeLevels();
this._emitLine('} catch (e) {');
this._emitLine(' cb(runtime.handleError(e, lineno, colno));');
this._emitLine('}');
this._emitLine('}');
this.buffer = null;
};
_proto._addScopeLevel = function _addScopeLevel() {
this._scopeClosers += '})';
};
_proto._closeScopeLevels = function _closeScopeLevels() {
this._emitLine(this._scopeClosers + ';');
this._scopeClosers = '';
};
_proto._withScopedSyntax = function _withScopedSyntax(func) {

@@ -154,14 +113,9 @@ var _scopeClosers = this._scopeClosers;

func.call(this);
this._closeScopeLevels();
this._scopeClosers = _scopeClosers;
};
_proto._makeCallback = function _makeCallback(res) {
var err = this._tmpid();
return 'function(' + err + (res ? ',' + res : '') + ') {\n' + 'if(' + err + ') { cb(' + err + '); return; }';
};
_proto._tmpid = function _tmpid() {

@@ -171,10 +125,7 @@ this.lastId++;

};
_proto._templateName = function _templateName() {
return this.templateName == null ? 'undefined' : JSON.stringify(this.templateName);
};
_proto._compileChildren = function _compileChildren(node, frame) {
var _this2 = this;
node.children.forEach(function (child) {

@@ -184,10 +135,7 @@ _this2.compile(child, frame);

};
_proto._compileAggregate = function _compileAggregate(node, frame, startChar, endChar) {
var _this3 = this;
if (startChar) {
this._emit(startChar);
}
node.children.forEach(function (child, i) {

@@ -197,6 +145,4 @@ if (i > 0) {

}
_this3.compile(child, frame);
});
if (endChar) {

@@ -206,3 +152,2 @@ this._emit(endChar);

};
_proto._compileExpression = function _compileExpression(node, frame) {

@@ -214,3 +159,2 @@ // TODO: I'm not really sure if this type check is worth it or

};
_proto.assertType = function assertType(node) {

@@ -220,3 +164,2 @@ for (var _len2 = arguments.length, types = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {

}
if (!types.some(function (t) {

@@ -228,22 +171,15 @@ return node instanceof t;

};
_proto.compileCallExtension = function compileCallExtension(node, frame, async) {
var _this4 = this;
var args = node.args;
var contentArgs = node.contentArgs;
var autoescape = typeof node.autoescape === 'boolean' ? node.autoescape : true;
if (!async) {
this._emit(this.buffer + " += runtime.suppressValue(");
}
this._emit("env.getExtension(\"" + node.extName + "\")[\"" + node.prop + "\"](");
this._emit('context');
if (args || contentArgs) {
this._emit(',');
}
if (args) {

@@ -253,3 +189,2 @@ if (!(args instanceof nodes.NodeList)) {

}
args.children.forEach(function (arg, i) {

@@ -260,3 +195,2 @@ // Tag arguments are passed normally to the call. Note

_this4._compileExpression(arg, frame);
if (i !== args.children.length - 1 || contentArgs.length) {

@@ -267,3 +201,2 @@ _this4._emit(',');

}
if (contentArgs.length) {

@@ -274,20 +207,12 @@ contentArgs.forEach(function (arg, i) {

}
if (arg) {
_this4._emitLine('function(cb) {');
_this4._emitLine('if(!cb) { cb = function(err) { if(err) { throw err; }}}');
var id = _this4._pushBuffer();
_this4._withScopedSyntax(function () {
_this4.compile(arg, frame);
_this4._emitLine("cb(null, " + id + ");");
});
_this4._popBuffer();
_this4._emitLine("return " + id + ";");
_this4._emitLine('}');

@@ -299,26 +224,18 @@ } else {

}
if (async) {
var res = this._tmpid();
this._emitLine(', ' + this._makeCallback(res));
this._emitLine(this.buffer + " += runtime.suppressValue(" + res + ", " + autoescape + " && env.opts.autoescape);");
this._addScopeLevel();
} else {
this._emit(')');
this._emit(", " + autoescape + " && env.opts.autoescape);\n");
}
};
_proto.compileCallExtensionAsync = function compileCallExtensionAsync(node, frame) {
this.compileCallExtension(node, frame, true);
};
_proto.compileNodeList = function compileNodeList(node, frame) {
this._compileChildren(node, frame);
};
_proto.compileLiteral = function compileLiteral(node) {

@@ -332,3 +249,2 @@ if (typeof node.value === 'string') {

val = val.replace(/\u2028/g, "\\u2028");
this._emit("\"" + val + "\"");

@@ -341,7 +257,5 @@ } else if (node.value === null) {

};
_proto.compileSymbol = function compileSymbol(node, frame) {
var name = node.value;
var v = frame.lookup(name);
if (v) {

@@ -353,19 +267,14 @@ this._emit(v);

};
_proto.compileGroup = function compileGroup(node, frame) {
this._compileAggregate(node, frame, '(', ')');
};
_proto.compileArray = function compileArray(node, frame) {
this._compileAggregate(node, frame, '[', ']');
};
_proto.compileDict = function compileDict(node, frame) {
this._compileAggregate(node, frame, '{', '}');
};
_proto.compilePair = function compilePair(node, frame) {
var key = node.key;
var val = node.value;
if (key instanceof nodes.Symbol) {

@@ -376,21 +285,12 @@ key = new nodes.Literal(key.lineno, key.colno, key.value);

}
this.compile(key, frame);
this._emit(': ');
this._compileExpression(val, frame);
};
_proto.compileInlineIf = function compileInlineIf(node, frame) {
this._emit('(');
this.compile(node.cond, frame);
this._emit('?');
this.compile(node.body, frame);
this._emit(':');
if (node.else_ !== null) {

@@ -401,144 +301,100 @@ this.compile(node.else_, frame);

}
this._emit(')');
};
_proto.compileIn = function compileIn(node, frame) {
this._emit('runtime.inOperator(');
this.compile(node.left, frame);
this._emit(',');
this.compile(node.right, frame);
this._emit(')');
};
_proto.compileIs = function compileIs(node, frame) {
// first, we need to try to get the name of the test function, if it's a
// callable (i.e., has args) and not a symbol.
var right = node.right.name ? node.right.name.value // otherwise go with the symbol value
var right = node.right.name ? node.right.name.value
// otherwise go with the symbol value
: node.right.value;
this._emit('env.getTest("' + right + '").call(context, ');
this.compile(node.left, frame); // compile the arguments for the callable if they exist
this.compile(node.left, frame);
// compile the arguments for the callable if they exist
if (node.right.args) {
this._emit(',');
this.compile(node.right.args, frame);
}
this._emit(') === true');
};
_proto._binOpEmitter = function _binOpEmitter(node, frame, str) {
this.compile(node.left, frame);
this._emit(str);
this.compile(node.right, frame);
}
this.compile(node.right, frame);
} // ensure concatenation instead of addition
// ensure concatenation instead of addition
// by adding empty string in between
;
_proto.compileOr = function compileOr(node, frame) {
return this._binOpEmitter(node, frame, ' || ');
};
_proto.compileAnd = function compileAnd(node, frame) {
return this._binOpEmitter(node, frame, ' && ');
};
_proto.compileAdd = function compileAdd(node, frame) {
return this._binOpEmitter(node, frame, ' + ');
};
_proto.compileConcat = function compileConcat(node, frame) {
return this._binOpEmitter(node, frame, ' + "" + ');
};
_proto.compileSub = function compileSub(node, frame) {
return this._binOpEmitter(node, frame, ' - ');
};
_proto.compileMul = function compileMul(node, frame) {
return this._binOpEmitter(node, frame, ' * ');
};
_proto.compileDiv = function compileDiv(node, frame) {
return this._binOpEmitter(node, frame, ' / ');
};
_proto.compileMod = function compileMod(node, frame) {
return this._binOpEmitter(node, frame, ' % ');
};
_proto.compileNot = function compileNot(node, frame) {
this._emit('!');
this.compile(node.target, frame);
};
_proto.compileFloorDiv = function compileFloorDiv(node, frame) {
this._emit('Math.floor(');
this.compile(node.left, frame);
this._emit(' / ');
this.compile(node.right, frame);
this._emit(')');
};
_proto.compilePow = function compilePow(node, frame) {
this._emit('Math.pow(');
this.compile(node.left, frame);
this._emit(', ');
this.compile(node.right, frame);
this._emit(')');
};
_proto.compileNeg = function compileNeg(node, frame) {
this._emit('-');
this.compile(node.target, frame);
};
_proto.compilePos = function compilePos(node, frame) {
this._emit('+');
this.compile(node.target, frame);
};
_proto.compileCompare = function compileCompare(node, frame) {
var _this5 = this;
this.compile(node.expr, frame);
node.ops.forEach(function (op) {
_this5._emit(" " + compareOps[op.type] + " ");
_this5.compile(op.expr, frame);
});
};
_proto.compileLookupVal = function compileLookupVal(node, frame) {
this._emit('runtime.memberLookup((');
this._compileExpression(node.target, frame);
this._emit('),');
this._compileExpression(node.val, frame);
this._emit(')');
};
_proto._getNodeName = function _getNodeName(node) {

@@ -548,12 +404,8 @@ switch (node.typename) {

return node.value;
case 'FunCall':
return 'the return value of (' + this._getNodeName(node.name) + ')';
case 'LookupVal':
return this._getNodeName(node.target) + '["' + this._getNodeName(node.val) + '"]';
case 'Literal':
return node.value.toString();
default:

@@ -563,3 +415,2 @@ return '--expression--';

};
_proto.compileFunCall = function compileFunCall(node, frame) {

@@ -571,28 +422,19 @@ // Keep track of line/col info at runtime by settings

this._emit('(lineno = ' + node.lineno + ', colno = ' + node.colno + ', ');
this._emit('runtime.callWrap(');
// Compile it as normal.
this._compileExpression(node.name, frame);
this._emit('runtime.callWrap('); // Compile it as normal.
this._compileExpression(node.name, frame); // Output the name of what we're calling so we can get friendly errors
// Output the name of what we're calling so we can get friendly errors
// if the lookup fails.
this._emit(', "' + this._getNodeName(node.name).replace(/"/g, '\\"') + '", context, ');
this._compileAggregate(node.args, frame, '[', '])');
this._emit(')');
};
_proto.compileFilter = function compileFilter(node, frame) {
var name = node.name;
this.assertType(name, nodes.Symbol);
this._emit('env.getFilter("' + name.value + '").call(context, ');
this._compileAggregate(node.args, frame);
this._emit(')');
};
_proto.compileFilterAsync = function compileFilterAsync(node, frame) {

@@ -603,72 +445,52 @@ var name = node.name;

frame.set(symbol, symbol);
this._emit('env.getFilter("' + name.value + '").call(context, ');
this._compileAggregate(node.args, frame);
this._emitLine(', ' + this._makeCallback(symbol));
this._addScopeLevel();
};
_proto.compileKeywordArgs = function compileKeywordArgs(node, frame) {
this._emit('runtime.makeKeywordArgs(');
this.compileDict(node, frame);
this._emit(')');
};
_proto.compileSet = function compileSet(node, frame) {
var _this6 = this;
var ids = [];
var ids = []; // Lookup the variable names for each identifier and create
// Lookup the variable names for each identifier and create
// new ones if necessary
node.targets.forEach(function (target) {
var name = target.value;
var id = frame.lookup(name);
if (id === null || id === undefined) {
id = _this6._tmpid();
if (id === null || id === undefined) {
id = _this6._tmpid(); // Note: This relies on js allowing scope across
// Note: This relies on js allowing scope across
// blocks, in case this is created inside an `if`
_this6._emitLine('var ' + id + ';');
}
ids.push(id);
});
if (node.value) {
this._emit(ids.join(' = ') + ' = ');
this._compileExpression(node.value, frame);
this._emitLine(';');
} else {
this._emit(ids.join(' = ') + ' = ');
this.compile(node.body, frame);
this._emitLine(';');
}
node.targets.forEach(function (target, i) {
var id = ids[i];
var name = target.value; // We are running this for every var, but it's very
var name = target.value;
// We are running this for every var, but it's very
// uncommon to assign to multiple vars anyway
_this6._emitLine("frame.set(\"" + name + "\", " + id + ", true);");
_this6._emitLine('if(frame.topLevel) {');
_this6._emitLine("context.setVariable(\"" + name + "\", " + id + ");");
_this6._emitLine('}');
if (name.charAt(0) !== '_') {
_this6._emitLine('if(frame.topLevel) {');
_this6._emitLine("context.addExport(\"" + name + "\", " + id + ");");
_this6._emitLine('}');

@@ -678,22 +500,13 @@ }

};
_proto.compileSwitch = function compileSwitch(node, frame) {
var _this7 = this;
this._emit('switch (');
this.compile(node.expr, frame);
this._emit(') {');
node.cases.forEach(function (c, i) {
_this7._emit('case ');
_this7.compile(c.cond, frame);
_this7._emit(': ');
_this7.compile(c.body, frame); // preserve fall-throughs
_this7.compile(c.body, frame);
// preserve fall-throughs
if (c.body.children.length) {

@@ -703,24 +516,15 @@ _this7._emitLine('break;');

});
if (node.default) {
this._emit('default:');
this.compile(node.default, frame);
}
this._emit('}');
};
_proto.compileIf = function compileIf(node, frame, async) {
var _this8 = this;
this._emit('if(');
this._compileExpression(node.cond, frame);
this._emitLine(') {');
this._withScopedSyntax(function () {
_this8.compile(node.body, frame);
if (async) {

@@ -730,9 +534,6 @@ _this8._emit('cb()');

});
if (node.else_) {
this._emitLine('}\nelse {');
this._withScopedSyntax(function () {
_this8.compile(node.else_, frame);
if (async) {

@@ -744,22 +545,14 @@ _this8._emit('cb()');

this._emitLine('}\nelse {');
this._emit('cb()');
}
this._emitLine('}');
};
_proto.compileIfAsync = function compileIfAsync(node, frame) {
this._emit('(function(cb) {');
this.compileIf(node, frame, true);
this._emit('})(' + this._makeCallback());
this._addScopeLevel();
};
_proto._emitLoopBindings = function _emitLoopBindings(node, arr, i, len) {
var _this9 = this;
var bindings = [{

@@ -791,98 +584,64 @@ name: 'index',

};
_proto.compileFor = function compileFor(node, frame) {
var _this10 = this;
// Some of this code is ugly, but it keeps the generated code
// as fast as possible. ForAsync also shares some of this, but
// not much.
var i = this._tmpid();
var len = this._tmpid();
var arr = this._tmpid();
frame = frame.push();
this._emitLine('frame = frame.push();');
this._emit("var " + arr + " = ");
this._compileExpression(node.arr, frame);
this._emitLine(';');
this._emit("if(" + arr + ") {");
this._emitLine(arr + ' = runtime.fromIterator(' + arr + ');');
this._emitLine(arr + ' = runtime.fromIterator(' + arr + ');'); // If multiple names are passed, we need to bind them
// If multiple names are passed, we need to bind them
// appropriately
if (node.name instanceof nodes.Array) {
this._emitLine("var " + i + ";");
if (node.name instanceof nodes.Array) {
this._emitLine("var " + i + ";"); // The object could be an arroy or object. Note that the
// The object could be an arroy or object. Note that the
// body of the loop is duplicated for each condition, but
// we are optimizing for speed over size.
this._emitLine("if(runtime.isArray(" + arr + ")) {");
this._emitLine("var " + len + " = " + arr + ".length;");
this._emitLine("for(" + i + "=0; " + i + " < " + arr + ".length; " + i + "++) {");
this._emitLine("for(" + i + "=0; " + i + " < " + arr + ".length; " + i + "++) {"); // Bind each declared var
// Bind each declared var
node.name.children.forEach(function (child, u) {
var tid = _this10._tmpid();
_this10._emitLine("var " + tid + " = " + arr + "[" + i + "][" + u + "];");
_this10._emitLine("frame.set(\"" + child + "\", " + arr + "[" + i + "][" + u + "]);");
frame.set(node.name.children[u].value, tid);
});
this._emitLoopBindings(node, arr, i, len);
this._withScopedSyntax(function () {
_this10.compile(node.body, frame);
});
this._emitLine('}');
this._emitLine('} else {'); // Iterate over the key/values of an object
this._emitLine('} else {');
// Iterate over the key/values of an object
var _node$name$children = node.name.children,
key = _node$name$children[0],
val = _node$name$children[1];
key = _node$name$children[0],
val = _node$name$children[1];
var k = this._tmpid();
var v = this._tmpid();
frame.set(key.value, k);
frame.set(val.value, v);
this._emitLine(i + " = -1;");
this._emitLine("var " + len + " = runtime.keys(" + arr + ").length;");
this._emitLine("for(var " + k + " in " + arr + ") {");
this._emitLine(i + "++;");
this._emitLine("var " + v + " = " + arr + "[" + k + "];");
this._emitLine("frame.set(\"" + key.value + "\", " + k + ");");
this._emitLine("frame.set(\"" + val.value + "\", " + v + ");");
this._emitLoopBindings(node, arr, i, len);
this._withScopedSyntax(function () {
_this10.compile(node.body, frame);
});
this._emitLine('}');
this._emitLine('}');

@@ -892,73 +651,46 @@ } else {

var _v = this._tmpid();
frame.set(node.name.value, _v);
this._emitLine("var " + len + " = " + arr + ".length;");
this._emitLine("for(var " + i + "=0; " + i + " < " + arr + ".length; " + i + "++) {");
this._emitLine("var " + _v + " = " + arr + "[" + i + "];");
this._emitLine("frame.set(\"" + node.name.value + "\", " + _v + ");");
this._emitLoopBindings(node, arr, i, len);
this._withScopedSyntax(function () {
_this10.compile(node.body, frame);
});
this._emitLine('}');
}
this._emitLine('}');
if (node.else_) {
this._emitLine('if (!' + len + ') {');
this.compile(node.else_, frame);
this._emitLine('}');
}
this._emitLine('frame = frame.pop();');
};
_proto._compileAsyncLoop = function _compileAsyncLoop(node, frame, parallel) {
var _this11 = this;
// This shares some code with the For tag, but not enough to
// worry about. This iterates across an object asynchronously,
// but not in parallel.
var i = this._tmpid();
var len = this._tmpid();
var arr = this._tmpid();
var asyncMethod = parallel ? 'asyncAll' : 'asyncEach';
frame = frame.push();
this._emitLine('frame = frame.push();');
this._emit('var ' + arr + ' = runtime.fromIterator(');
this._compileExpression(node.arr, frame);
this._emitLine(');');
if (node.name instanceof nodes.Array) {
var arrayLen = node.name.children.length;
this._emit("runtime." + asyncMethod + "(" + arr + ", " + arrayLen + ", function(");
node.name.children.forEach(function (name) {
_this11._emit(name.value + ",");
});
this._emit(i + ',' + len + ',next) {');
node.name.children.forEach(function (name) {
var id = name.value;
frame.set(id, id);
_this11._emitLine("frame.set(\"" + id + "\", " + id + ");");

@@ -968,23 +700,14 @@ });

var id = node.name.value;
this._emitLine("runtime." + asyncMethod + "(" + arr + ", 1, function(" + id + ", " + i + ", " + len + ",next) {");
this._emitLine('frame.set("' + id + '", ' + id + ');');
frame.set(id, id);
}
this._emitLoopBindings(node, arr, i, len);
this._withScopedSyntax(function () {
var buf;
if (parallel) {
buf = _this11._pushBuffer();
}
_this11.compile(node.body, frame);
_this11._emitLine('next(' + i + (buf ? ',' + buf : '') + ');');
if (parallel) {

@@ -994,42 +717,29 @@ _this11._popBuffer();

});
var output = this._tmpid();
this._emitLine('}, ' + this._makeCallback(output));
this._addScopeLevel();
if (parallel) {
this._emitLine(this.buffer + ' += ' + output + ';');
}
if (node.else_) {
this._emitLine('if (!' + arr + '.length) {');
this.compile(node.else_, frame);
this._emitLine('}');
}
this._emitLine('frame = frame.pop();');
};
_proto.compileAsyncEach = function compileAsyncEach(node, frame) {
this._compileAsyncLoop(node, frame);
};
_proto.compileAsyncAll = function compileAsyncAll(node, frame) {
this._compileAsyncLoop(node, frame, true);
};
_proto._compileMacro = function _compileMacro(node, frame) {
var _this12 = this;
var args = [];
var kwargs = null;
var funcId = 'macro_' + this._tmpid();
var keepFrame = frame !== undefined;
var keepFrame = frame !== undefined; // Type check the definition of the args
// Type check the definition of the args
node.args.children.forEach(function (arg, i) {

@@ -1040,3 +750,2 @@ if (i === node.args.children.length - 1 && arg instanceof nodes.Dict) {

_this12.assertType(arg, nodes.Symbol);
args.push(arg);

@@ -1047,4 +756,5 @@ }

return "l_" + n.value;
}), ['kwargs']); // Quoted argument names
}), ['kwargs']);
// Quoted argument names
var argNames = args.map(function (n) {

@@ -1055,9 +765,9 @@ return "\"" + n.value + "\"";

return "\"" + n.key.value + "\"";
}); // We pass a function to makeMacro which destructures the
});
// We pass a function to makeMacro which destructures the
// arguments so support setting positional args with keywords
// args and passing keyword args as positional args
// (essentially default values). See runtime.js.
var currFrame;
if (keepFrame) {

@@ -1068,54 +778,39 @@ currFrame = frame.push(true);

}
this._emitLines("var " + funcId + " = runtime.makeMacro(", "[" + argNames.join(', ') + "], ", "[" + kwargNames.join(', ') + "], ", "function (" + realNames.join(', ') + ") {", 'var callerFrame = frame;', 'frame = ' + (keepFrame ? 'frame.push(true);' : 'new runtime.Frame();'), 'kwargs = kwargs || {};', 'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {', 'frame.set("caller", kwargs.caller); }');
this._emitLines("var " + funcId + " = runtime.makeMacro(", "[" + argNames.join(', ') + "], ", "[" + kwargNames.join(', ') + "], ", "function (" + realNames.join(', ') + ") {", 'var callerFrame = frame;', 'frame = ' + (keepFrame ? 'frame.push(true);' : 'new runtime.Frame();'), 'kwargs = kwargs || {};', 'if (Object.prototype.hasOwnProperty.call(kwargs, "caller")) {', 'frame.set("caller", kwargs.caller); }'); // Expose the arguments to the template. Don't need to use
// Expose the arguments to the template. Don't need to use
// random names because the function
// will create a new run-time scope for us
args.forEach(function (arg) {
_this12._emitLine("frame.set(\"" + arg.value + "\", l_" + arg.value + ");");
currFrame.set(arg.value, "l_" + arg.value);
}); // Expose the keyword arguments
});
// Expose the keyword arguments
if (kwargs) {
kwargs.children.forEach(function (pair) {
var name = pair.key.value;
_this12._emit("frame.set(\"" + name + "\", ");
_this12._emit("Object.prototype.hasOwnProperty.call(kwargs, \"" + name + "\")");
_this12._emit(" ? kwargs[\"" + name + "\"] : ");
_this12._compileExpression(pair.value, currFrame);
_this12._emit(');');
});
}
var bufferId = this._pushBuffer();
this._withScopedSyntax(function () {
_this12.compile(node.body, currFrame);
});
this._emitLine('frame = ' + (keepFrame ? 'frame.pop();' : 'callerFrame;'));
this._emitLine("return new runtime.SafeString(" + bufferId + ");");
this._emitLine('});');
this._popBuffer();
return funcId;
};
_proto.compileMacro = function compileMacro(node, frame) {
var funcId = this._compileMacro(node); // Expose the macro to the templates
var funcId = this._compileMacro(node);
// Expose the macro to the templates
var name = node.name.value;
frame.set(name, funcId);
if (frame.parent) {

@@ -1127,48 +822,29 @@ this._emitLine("frame.set(\"" + name + "\", " + funcId + ");");

}
this._emitLine("context.setVariable(\"" + name + "\", " + funcId + ");");
}
};
_proto.compileCaller = function compileCaller(node, frame) {
// basically an anonymous "macro expression"
this._emit('(function (){');
var funcId = this._compileMacro(node, frame);
this._emit("return " + funcId + ";})()");
};
_proto._compileGetTemplate = function _compileGetTemplate(node, frame, eagerCompile, ignoreMissing) {
var parentTemplateId = this._tmpid();
var parentName = this._templateName();
var cb = this._makeCallback(parentTemplateId);
var eagerCompileArg = eagerCompile ? 'true' : 'false';
var ignoreMissingArg = ignoreMissing ? 'true' : 'false';
this._emit('env.getTemplate(');
this._compileExpression(node.template, frame);
this._emitLine(", " + eagerCompileArg + ", " + parentName + ", " + ignoreMissingArg + ", " + cb);
return parentTemplateId;
};
_proto.compileImport = function compileImport(node, frame) {
var target = node.target.value;
var id = this._compileGetTemplate(node, frame, false, false);
this._addScopeLevel();
this._emitLine(id + '.getExported(' + (node.withContext ? 'context.getVariables(), frame, ' : '') + this._makeCallback(id));
this._addScopeLevel();
frame.set(target, id);
if (frame.parent) {

@@ -1180,20 +856,12 @@ this._emitLine("frame.set(\"" + target + "\", " + id + ");");

};
_proto.compileFromImport = function compileFromImport(node, frame) {
var _this13 = this;
var importedId = this._compileGetTemplate(node, frame, false, false);
this._addScopeLevel();
this._emitLine(importedId + '.getExported(' + (node.withContext ? 'context.getVariables(), frame, ' : '') + this._makeCallback(importedId));
this._addScopeLevel();
node.names.children.forEach(function (nameNode) {
var name;
var alias;
var id = _this13._tmpid();
if (nameNode instanceof nodes.Pair) {

@@ -1206,15 +874,8 @@ name = nameNode.key.value;

}
_this13._emitLine("if(Object.prototype.hasOwnProperty.call(" + importedId + ", \"" + name + "\")) {");
_this13._emitLine("var " + id + " = " + importedId + "." + name + ";");
_this13._emitLine('} else {');
_this13._emitLine("cb(new Error(\"cannot import '" + name + "'\")); return;");
_this13._emitLine('}');
frame.set(alias, id);
if (frame.parent) {

@@ -1227,5 +888,6 @@ _this13._emitLine("frame.set(\"" + alias + "\", " + id + ");");

};
_proto.compileBlock = function compileBlock(node) {
var id = this._tmpid();
_proto.compileBlock = function compileBlock(node) {
var id = this._tmpid(); // If we are executing outside a block (creating a top-level
// If we are executing outside a block (creating a top-level
// block), we really don't want to execute its code because it

@@ -1240,102 +902,61 @@ // will execute twice: once when the child template runs and

// blocks twice
if (!this.inBlock) {
this._emit('(parentTemplate ? function(e, c, f, r, cb) { cb(""); } : ');
}
this._emit("context.getBlock(\"" + node.name.value + "\")");
if (!this.inBlock) {
this._emit(')');
}
this._emitLine('(env, context, frame, runtime, ' + this._makeCallback(id));
this._emitLine(this.buffer + " += " + id + ";");
this._addScopeLevel();
};
_proto.compileSuper = function compileSuper(node, frame) {
var name = node.blockName.value;
var id = node.symbol.value;
var cb = this._makeCallback(id);
this._emitLine("context.getSuper(env, \"" + name + "\", b_" + name + ", frame, runtime, " + cb);
this._emitLine(id + " = runtime.markSafe(" + id + ");");
this._addScopeLevel();
frame.set(id, id);
};
_proto.compileExtends = function compileExtends(node, frame) {
var k = this._tmpid();
var parentTemplateId = this._compileGetTemplate(node, frame, true, false);
var parentTemplateId = this._compileGetTemplate(node, frame, true, false); // extends is a dynamic tag and can occur within a block like
// extends is a dynamic tag and can occur within a block like
// `if`, so if this happens we need to capture the parent
// template in the top-level scope
this._emitLine("parentTemplate = " + parentTemplateId);
this._emitLine("for(var " + k + " in parentTemplate.blocks) {");
this._emitLine("context.addBlock(" + k + ", parentTemplate.blocks[" + k + "]);");
this._emitLine('}');
this._addScopeLevel();
};
_proto.compileInclude = function compileInclude(node, frame) {
this._emitLine('var tasks = [];');
this._emitLine('tasks.push(');
this._emitLine('function(callback) {');
var id = this._compileGetTemplate(node, frame, false, node.ignoreMissing);
this._emitLine("callback(null," + id + ");});");
this._emitLine('});');
var id2 = this._tmpid();
this._emitLine('tasks.push(');
this._emitLine('function(template, callback){');
this._emitLine('template.render(context.getVariables(), frame, ' + this._makeCallback(id2));
this._emitLine('callback(null,' + id2 + ');});');
this._emitLine('});');
this._emitLine('tasks.push(');
this._emitLine('function(result, callback){');
this._emitLine(this.buffer + " += result;");
this._emitLine('callback(null);');
this._emitLine('});');
this._emitLine('env.waterfall(tasks, function(){');
this._addScopeLevel();
};
_proto.compileTemplateData = function compileTemplateData(node, frame) {
this.compileLiteral(node, frame);
};
_proto.compileCapture = function compileCapture(node, frame) {
var _this14 = this;
// we need to temporarily override the current buffer id as 'output'

@@ -1345,22 +966,14 @@ // so the set block writes to the capture output instead of the buffer

this.buffer = 'output';
this._emitLine('(function() {');
this._emitLine('var output = "";');
this._withScopedSyntax(function () {
_this14.compile(node.body, frame);
});
this._emitLine('return output;');
this._emitLine('})()'); // and of course, revert back to the old buffer id
this._emitLine('})()');
// and of course, revert back to the old buffer id
this.buffer = buffer;
};
_proto.compileOutput = function compileOutput(node, frame) {
var _this15 = this;
var children = node.children;

@@ -1373,5 +986,3 @@ children.forEach(function (child) {

_this15._emit(_this15.buffer + " += ");
_this15.compileLiteral(child, frame);
_this15._emitLine(';');

@@ -1381,13 +992,9 @@ }

_this15._emit(_this15.buffer + " += runtime.suppressValue(");
if (_this15.throwOnUndefined) {
_this15._emit('runtime.ensureDefined(');
}
_this15.compile(child, frame);
if (_this15.throwOnUndefined) {
_this15._emit("," + node.lineno + "," + node.colno + ")");
}
_this15._emit(', env.opts.autoescape);\n');

@@ -1397,30 +1004,17 @@ }

};
_proto.compileRoot = function compileRoot(node, frame) {
var _this16 = this;
if (frame) {
this.fail('compileRoot: root node can\'t have frame');
}
frame = new Frame();
this._emitFuncBegin(node, 'root');
this._emitLine('var parentTemplate = null;');
this._compileChildren(node, frame);
this._emitLine('if(parentTemplate) {');
this._emitLine('parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);');
this._emitLine('} else {');
this._emitLine("cb(null, " + this.buffer + ");");
this._emitLine('}');
this._emitFuncEnd(true);
this.inBlock = true;

@@ -1431,34 +1025,21 @@ var blockNames = [];

var name = block.name.value;
if (blockNames.indexOf(name) !== -1) {
throw new Error("Block \"" + name + "\" defined more than once.");
}
blockNames.push(name);
_this16._emitFuncBegin(block, "b_" + name);
var tmpFrame = new Frame();
_this16._emitLine('var frame = frame.push(true);');
_this16.compile(block.body, tmpFrame);
_this16._emitFuncEnd();
});
this._emitLine('return {');
blocks.forEach(function (block, i) {
var blockName = "b_" + block.name.value;
_this16._emitLine(blockName + ": " + blockName + ",");
});
this._emitLine('root: root\n};');
};
_proto.compile = function compile(node, frame) {
var _compile = this['compile' + node.typename];
if (_compile) {

@@ -1470,10 +1051,7 @@ _compile.call(this, node, frame);

};
_proto.getCode = function getCode() {
return this.codebuf.join('');
};
return Compiler;
}(Obj);
module.exports = {

@@ -1484,5 +1062,5 @@ compile: function compile(src, asyncFilters, extensions, name, opts) {

}
var c = new Compiler(name, opts.throwOnUndefined);
var c = new Compiler(name, opts.throwOnUndefined); // Run the extension preprocessors against the source.
// Run the extension preprocessors against the source.
var preprocessors = (extensions || []).map(function (ext) {

@@ -1489,0 +1067,0 @@ return ext.preprocess;

'use strict';
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var asap = require('asap');
var _waterfall = require('a-sync-waterfall');
var lib = require('./lib');
var compiler = require('./compiler');
var filters = require('./filters');
var _require = require('./loaders'),
FileSystemLoader = _require.FileSystemLoader,
WebLoader = _require.WebLoader,
PrecompiledLoader = _require.PrecompiledLoader;
FileSystemLoader = _require.FileSystemLoader,
WebLoader = _require.WebLoader,
PrecompiledLoader = _require.PrecompiledLoader;
var tests = require('./tests');
var globals = require('./globals');
var _require2 = require('./object'),
Obj = _require2.Obj,
EmitterObj = _require2.EmitterObj;
Obj = _require2.Obj,
EmitterObj = _require2.EmitterObj;
var globalRuntime = require('./runtime');
var handleError = globalRuntime.handleError,
Frame = globalRuntime.Frame;
Frame = globalRuntime.Frame;
var expressApp = require('./express-app');
var expressApp = require('./express-app'); // If the user is using the async API, *always* call it
// If the user is using the async API, *always* call it
// asynchronously even if the template was synchronous.
function callbackAsap(cb, err, res) {

@@ -44,7 +31,6 @@ asap(function () {

}
/**
* A no-op template, for use with {% include ignore missing %}
*/
var noopTmplSrc = {

@@ -62,15 +48,10 @@ type: 'code',

};
var Environment = /*#__PURE__*/function (_EmitterObj) {
_inheritsLoose(Environment, _EmitterObj);
function Environment() {
return _EmitterObj.apply(this, arguments) || this;
}
var _proto = Environment.prototype;
_proto.init = function init(loaders, opts) {
var _this = this;
// The dev flag determines the trace that'll be shown on errors.

@@ -83,10 +64,12 @@ // If set to true, returns the full trace from the error point,

opts = this.opts = opts || {};
this.opts.dev = !!opts.dev; // The autoescape flag sets global autoescaping. If true,
this.opts.dev = !!opts.dev;
// The autoescape flag sets global autoescaping. If true,
// every string variable will be escaped by default.
// If false, strings can be manually escaped using the `escape` filter.
// defaults to true
this.opts.autoescape = opts.autoescape != null ? opts.autoescape : true;
this.opts.autoescape = opts.autoescape != null ? opts.autoescape : true; // If true, this will make the system throw errors if trying
// If true, this will make the system throw errors if trying
// to output a null or undefined value
this.opts.throwOnUndefined = !!opts.throwOnUndefined;

@@ -96,3 +79,2 @@ this.opts.trimBlocks = !!opts.trimBlocks;

this.loaders = [];
if (!loaders) {

@@ -107,13 +89,11 @@ // The filesystem loader is only available server-side

this.loaders = lib.isArray(loaders) ? loaders : [loaders];
} // It's easy to use precompiled templates: just include them
}
// It's easy to use precompiled templates: just include them
// before you configure nunjucks and this will automatically
// pick it up and use it
if (typeof window !== 'undefined' && window.nunjucksPrecompiled) {
this.loaders.unshift(new PrecompiledLoader(window.nunjucksPrecompiled));
}
this._initLoaders();
this.globals = globals();

@@ -125,27 +105,21 @@ this.filters = {};

this.extensionsList = [];
lib._entries(filters).forEach(function (_ref) {
var name = _ref[0],
filter = _ref[1];
filter = _ref[1];
return _this.addFilter(name, filter);
});
lib._entries(tests).forEach(function (_ref2) {
var name = _ref2[0],
test = _ref2[1];
test = _ref2[1];
return _this.addTest(name, test);
});
};
_proto._initLoaders = function _initLoaders() {
var _this2 = this;
this.loaders.forEach(function (loader) {
// Caching and cache busting
loader.cache = {};
if (typeof loader.on === 'function') {
loader.on('update', function (name, fullname) {
loader.cache[name] = null;
_this2.emit('update', name, fullname, loader);

@@ -159,3 +133,2 @@ });

};
_proto.invalidateCache = function invalidateCache() {

@@ -166,3 +139,2 @@ this.loaders.forEach(function (loader) {

};
_proto.addExtension = function addExtension(name, extension) {

@@ -174,22 +146,16 @@ extension.__name = name;

};
_proto.removeExtension = function removeExtension(name) {
var extension = this.getExtension(name);
if (!extension) {
return;
}
this.extensionsList = lib.without(this.extensionsList, extension);
delete this.extensions[name];
};
_proto.getExtension = function getExtension(name) {
return this.extensions[name];
};
_proto.hasExtension = function hasExtension(name) {
return !!this.extensions[name];
};
_proto.addGlobal = function addGlobal(name, value) {

@@ -199,3 +165,2 @@ this.globals[name] = value;

};
_proto.getGlobal = function getGlobal(name) {

@@ -205,17 +170,12 @@ if (typeof this.globals[name] === 'undefined') {

}
return this.globals[name];
};
_proto.addFilter = function addFilter(name, func, async) {
var wrapped = func;
if (async) {
this.asyncFilters.push(name);
}
this.filters[name] = wrapped;
return this;
};
_proto.getFilter = function getFilter(name) {

@@ -225,6 +185,4 @@ if (!this.filters[name]) {

}
return this.filters[name];
};
_proto.addTest = function addTest(name, func) {

@@ -234,3 +192,2 @@ this.tests[name] = func;

};
_proto.getTest = function getTest(name) {

@@ -240,6 +197,4 @@ if (!this.tests[name]) {

}
return this.tests[name];
};
_proto.resolveTemplate = function resolveTemplate(loader, parentName, filename) {

@@ -249,9 +204,6 @@ var isRelative = loader.isRelative && parentName ? loader.isRelative(filename) : false;

};
_proto.getTemplate = function getTemplate(name, eagerCompile, parentName, ignoreMissing, cb) {
var _this3 = this;
var that = this;
var tmpl = null;
if (name && name.raw) {

@@ -261,3 +213,2 @@ // this fixes autoescape for templates referenced in symbols

}
if (lib.isFunction(parentName)) {

@@ -268,3 +219,2 @@ cb = parentName;

}
if (lib.isFunction(eagerCompile)) {

@@ -274,3 +224,2 @@ cb = eagerCompile;

}
if (name instanceof Template) {

@@ -284,3 +233,2 @@ tmpl = name;

tmpl = loader.cache[this.resolveTemplate(loader, parentName, name)];
if (tmpl) {

@@ -291,3 +239,2 @@ break;

}
if (tmpl) {

@@ -297,3 +244,2 @@ if (eagerCompile) {

}
if (cb) {

@@ -306,5 +252,3 @@ cb(null, tmpl);

}
var syncResult;
var createTemplate = function createTemplate(err, info) {

@@ -314,3 +258,2 @@ if (!info && !err && !ignoreMissing) {

}
if (err) {

@@ -324,5 +267,3 @@ if (cb) {

}
var newTmpl;
if (!info) {

@@ -332,3 +273,2 @@ newTmpl = new Template(noopTmplSrc, _this3, '', eagerCompile);

newTmpl = new Template(info.src, _this3, info.path, eagerCompile);
if (!info.noCache) {

@@ -338,3 +278,2 @@ info.loader.cache[name] = newTmpl;

}
if (cb) {

@@ -346,3 +285,2 @@ cb(null, newTmpl);

};
lib.asyncIter(this.loaders, function (loader, i, next, done) {

@@ -358,7 +296,6 @@ function handle(err, src) {

}
} // Resolve name relative to parentName
}
// Resolve name relative to parentName
name = that.resolveTemplate(loader, parentName, name);
if (loader.async) {

@@ -372,7 +309,5 @@ loader.getSource(name, handle);

};
_proto.express = function express(app) {
return expressApp(this, app);
};
_proto.render = function render(name, ctx, cb) {

@@ -382,8 +317,8 @@ if (lib.isFunction(ctx)) {

ctx = null;
} // We support a synchronous API to make it easier to migrate
}
// We support a synchronous API to make it easier to migrate
// existing code to async. This works because if you don't do
// anything async work, the whole thing is actually run
// synchronously.
var syncResult = null;

@@ -401,3 +336,2 @@ this.getTemplate(name, function (err, tmpl) {

};
_proto.renderString = function renderString(src, ctx, opts, cb) {

@@ -408,3 +342,2 @@ if (lib.isFunction(opts)) {

}
opts = opts || {};

@@ -414,25 +347,19 @@ var tmpl = new Template(src, this, opts.path);

};
_proto.waterfall = function waterfall(tasks, callback, forceAsync) {
return _waterfall(tasks, callback, forceAsync);
};
return Environment;
}(EmitterObj);
var Context = /*#__PURE__*/function (_Obj) {
_inheritsLoose(Context, _Obj);
function Context() {
return _Obj.apply(this, arguments) || this;
}
var _proto2 = Context.prototype;
_proto2.init = function init(ctx, blocks, env) {
var _this4 = this;
// Has to be tied to an environment so we can tap into its globals.
this.env = env || new Environment(); // Make a duplicate of ctx
this.env = env || new Environment();
// Make a duplicate of ctx
this.ctx = lib.extend({}, ctx);

@@ -445,3 +372,2 @@ this.blocks = {};

};
_proto2.lookup = function lookup(name) {

@@ -456,11 +382,8 @@ // This is one of the most called functions, so optimize for

};
_proto2.setVariable = function setVariable(name, val) {
this.ctx[name] = val;
};
_proto2.getVariables = function getVariables() {
return this.ctx;
};
_proto2.addBlock = function addBlock(name, block) {

@@ -471,3 +394,2 @@ this.blocks[name] = this.blocks[name] || [];

};
_proto2.getBlock = function getBlock(name) {

@@ -477,6 +399,4 @@ if (!this.blocks[name]) {

}
return this.blocks[name][0];
};
_proto2.getSuper = function getSuper(env, name, block, frame, runtime, cb) {

@@ -486,17 +406,12 @@ var idx = lib.indexOf(this.blocks[name] || [], block);

var context = this;
if (idx === -1 || !blk) {
throw new Error('no super block available for "' + name + '"');
}
blk(env, context, frame, runtime, cb);
};
_proto2.addExport = function addExport(name) {
this.exported.push(name);
};
_proto2.getExported = function getExported() {
var _this5 = this;
var exported = {};

@@ -508,18 +423,12 @@ this.exported.forEach(function (name) {

};
return Context;
}(Obj);
var Template = /*#__PURE__*/function (_Obj2) {
_inheritsLoose(Template, _Obj2);
function Template() {
return _Obj2.apply(this, arguments) || this;
}
var _proto3 = Template.prototype;
_proto3.init = function init(src, env, path, eagerCompile) {
this.env = env || new Environment();
if (lib.isObject(src)) {

@@ -530,7 +439,5 @@ switch (src.type) {

break;
case 'string':
this.tmplStr = src.obj;
break;
default:

@@ -544,5 +451,3 @@ throw new Error("Unexpected template object type " + src.type + "; expected 'code', or 'string'");

}
this.path = path;
if (eagerCompile) {

@@ -558,6 +463,4 @@ try {

};
_proto3.render = function render(ctx, parentFrame, cb) {
var _this6 = this;
if (typeof ctx === 'function') {

@@ -569,10 +472,11 @@ cb = ctx;

parentFrame = null;
} // If there is a parent frame, we are being called from internal
}
// If there is a parent frame, we are being called from internal
// code of another template, and the internal system
// depends on the sync/async nature of the parent template
// to be inherited, so force an async callback
var forceAsync = !parentFrame;
var forceAsync = !parentFrame; // Catch compile errors for async rendering
// Catch compile errors for async rendering
try {

@@ -582,3 +486,2 @@ this.compile();

var err = lib._prettifyError(this.path, this.env.opts.dev, e);
if (cb) {

@@ -590,3 +493,2 @@ return callbackAsap(cb, err);

}
var context = new Context(ctx || {}, this.blocks, this.env);

@@ -606,3 +508,2 @@ var frame = parentFrame ? parentFrame.push(true) : new Frame();

}
if (err) {

@@ -612,3 +513,2 @@ err = lib._prettifyError(_this6.path, _this6.env.opts.dev, err);

}
if (cb) {

@@ -624,3 +524,2 @@ if (forceAsync) {

}
syncResult = res;

@@ -631,3 +530,2 @@ }

};
_proto3.getExported = function getExported(ctx, parentFrame, cb) {

@@ -639,9 +537,8 @@ // eslint-disable-line consistent-return

}
if (typeof parentFrame === 'function') {
cb = parentFrame;
parentFrame = null;
} // Catch compile errors for async rendering
}
// Catch compile errors for async rendering
try {

@@ -656,6 +553,6 @@ this.compile();

}
var frame = parentFrame ? parentFrame.push() : new Frame();
frame.topLevel = true; // Run the rootRenderFunc to populate the context with exported vars
frame.topLevel = true;
// Run the rootRenderFunc to populate the context with exported vars
var context = new Context(ctx || {}, this.blocks, this.env);

@@ -670,3 +567,2 @@ this.rootRenderFunc(this.env, context, frame, globalRuntime, function (err) {

};
_proto3.compile = function compile() {

@@ -677,6 +573,4 @@ if (!this.compiled) {

};
_proto3._compile = function _compile() {
var props;
if (this.tmplProps) {

@@ -687,6 +581,4 @@ props = this.tmplProps;

var func = new Function(source); // eslint-disable-line no-new-func
props = func();
}
this.blocks = this._getBlocks(props);

@@ -696,3 +588,2 @@ this.rootRenderFunc = props.root;

};
_proto3._getBlocks = function _getBlocks(props) {

@@ -707,6 +598,4 @@ var blocks = {};

};
return Template;
}(Obj);
module.exports = {

@@ -713,0 +602,0 @@ Environment: Environment,

"use strict";
var path = require('path');
module.exports = function express(env, app) {

@@ -11,7 +10,5 @@ function NunjucksView(name, opts) {

this.ext = path.extname(name);
if (!this.ext && !this.defaultEngine) {
throw new Error('No default engine was specified and no extension was provided.');
}
if (!this.ext) {

@@ -21,7 +18,5 @@ this.name += this.ext = (this.defaultEngine[0] !== '.' ? '.' : '') + this.defaultEngine;

}
NunjucksView.prototype.render = function render(opts, cb) {
env.render(this.name, opts, cb);
};
app.set('view', NunjucksView);

@@ -28,0 +23,0 @@ app.set('nunjucksEnv', env);

'use strict';
var lib = require('./lib');
var r = require('./runtime');
var _exports = module.exports = {};
function normalize(value, defaultValue) {

@@ -13,8 +10,5 @@ if (value === null || value === undefined || value === false) {

}
return value;
}
_exports.abs = Math.abs;
function isNaN(num) {

@@ -28,3 +22,2 @@ return num !== num; // eslint-disable-line no-self-compare

var tmp = [];
for (i = 0; i < arr.length; i++) {

@@ -35,6 +28,4 @@ if (i % linecount === 0 && tmp.length) {

}
tmp.push(arr[i]);
}
if (tmp.length) {

@@ -46,11 +37,7 @@ if (fillWith) {

}
res.push(tmp);
}
return res;
}
_exports.batch = batch;
function capitalize(str) {

@@ -61,13 +48,9 @@ str = normalize(str, '');

}
_exports.capitalize = capitalize;
function center(str, width) {
str = normalize(str, '');
width = width || 80;
if (str.length >= width) {
return str;
}
var spaces = width - str.length;

@@ -78,5 +61,3 @@ var pre = lib.repeat(' ', spaces / 2 - spaces % 2);

}
_exports.center = center;
function default_(val, def, bool) {

@@ -88,5 +69,5 @@ if (bool) {

}
} // TODO: it is confusing to export something called 'default'
}
// TODO: it is confusing to export something called 'default'
_exports['default'] = default_; // eslint-disable-line dot-notation

@@ -98,5 +79,4 @@

}
var array = []; // deliberately include properties from the object's prototype
var array = [];
// deliberately include properties from the object's prototype
for (var k in val) {

@@ -106,5 +86,3 @@ // eslint-disable-line guard-for-in, no-restricted-syntax

}
var si;
if (by === undefined || by === 'key') {

@@ -117,7 +95,5 @@ si = 0;

}
array.sort(function (t1, t2) {
var a = t1[si];
var b = t2[si];
if (!caseSensitive) {

@@ -127,3 +103,2 @@ if (lib.isString(a)) {

}
if (lib.isString(b)) {

@@ -133,16 +108,12 @@ b = b.toUpperCase();

}
return a > b ? 1 : a === b ? 0 : -1; // eslint-disable-line no-nested-ternary
});
return array;
}
_exports.dictsort = dictsort;
function dump(obj, spaces) {
return JSON.stringify(obj, null, spaces);
}
_exports.dump = dump;
function escape(str) {

@@ -152,9 +123,6 @@ if (str instanceof r.SafeString) {

}
str = str === null || str === undefined ? '' : str;
return r.markSafe(lib.escape(str.toString()));
}
_exports.escape = escape;
function safe(str) {

@@ -164,15 +132,10 @@ if (str instanceof r.SafeString) {

}
str = str === null || str === undefined ? '' : str;
return r.markSafe(str.toString());
}
_exports.safe = safe;
function first(arr) {
return arr[0];
}
_exports.first = first;
function forceescape(str) {

@@ -182,20 +145,14 @@ str = str === null || str === undefined ? '' : str;

}
_exports.forceescape = forceescape;
function groupby(arr, attr) {
return lib.groupBy(arr, attr, this.env.opts.throwOnUndefined);
}
_exports.groupby = groupby;
function indent(str, width, indentfirst) {
str = normalize(str, '');
if (str === '') {
return '';
}
width = width || 4; // let res = '';
width = width || 4;
// let res = '';
var lines = str.split('\n');

@@ -208,8 +165,5 @@ var sp = lib.repeat(' ', width);

}
_exports.indent = indent;
function join(arr, del, attr) {
del = del || '';
if (attr) {

@@ -220,17 +174,11 @@ arr = lib.map(arr, function (v) {

}
return arr.join(del);
}
_exports.join = join;
function last(arr) {
return arr[arr.length - 1];
}
_exports.last = last;
function lengthFilter(val) {
var value = normalize(val, '');
if (value !== undefined) {

@@ -241,3 +189,2 @@ if (typeof Map === 'function' && value instanceof Map || typeof Set === 'function' && value instanceof Set) {

}
if (lib.isObject(value) && !(value instanceof r.SafeString)) {

@@ -247,11 +194,7 @@ // Objects (besides SafeStrings), non-primative Arrays

}
return value.length;
}
return 0;
}
_exports.length = lengthFilter;
function list(val) {

@@ -263,3 +206,3 @@ if (lib.isString(val)) {

var key = _ref[0],
value = _ref[1];
value = _ref[1];
return {

@@ -276,5 +219,3 @@ key: key,

}
_exports.list = list;
function lower(str) {

@@ -284,5 +225,3 @@ str = normalize(str, '');

}
_exports.lower = lower;
function nl2br(str) {

@@ -292,13 +231,10 @@ if (str === null || str === undefined) {

}
return r.copySafeness(str, str.replace(/\r\n|\n/g, '<br />\n'));
}
_exports.nl2br = nl2br;
function random(arr) {
return arr[Math.floor(Math.random() * arr.length)];
}
_exports.random = random;
_exports.random = random;
/**

@@ -310,3 +246,2 @@ * Construct select or reject filter

*/
function getSelectOrReject(expectedTestResult) {

@@ -317,3 +252,2 @@ function filter(arr, testName, secondArg) {

}
var context = this;

@@ -325,8 +259,5 @@ var test = context.env.getTest(testName);

}
return filter;
}
_exports.reject = getSelectOrReject(false);
function rejectattr(arr, attr) {

@@ -337,6 +268,4 @@ return arr.filter(function (item) {

}
_exports.rejectattr = rejectattr;
_exports.select = getSelectOrReject(true);
function selectattr(arr, attr) {

@@ -347,19 +276,14 @@ return arr.filter(function (item) {

}
_exports.selectattr = selectattr;
function replace(str, old, new_, maxCount) {
var originalStr = str;
if (old instanceof RegExp) {
return str.replace(old, new_);
}
if (typeof maxCount === 'undefined') {
maxCount = -1;
}
var res = ''; // Output
var res = ''; // Output
// Cast Numbers in the search term to string
if (typeof old === 'number') {

@@ -371,15 +295,15 @@ old = '' + old;

return str;
} // Cast numbers in the replacement to string
}
// Cast numbers in the replacement to string
if (typeof str === 'number') {
str = '' + str;
} // If by now, we don't have a string, throw it back
}
// If by now, we don't have a string, throw it back
if (typeof str !== 'string' && !(str instanceof r.SafeString)) {
return str;
} // ShortCircuits
}
// ShortCircuits
if (old === '') {

@@ -391,10 +315,8 @@ // Mimic the python behaviour: empty string is replaced

}
var nextIndex = str.indexOf(old); // if # of replacements to perform is 0, or the string to does
var nextIndex = str.indexOf(old);
// if # of replacements to perform is 0, or the string to does
// not contain the old value, return the string
if (maxCount === 0 || nextIndex === -1) {
return str;
}
var pos = 0;

@@ -406,24 +328,20 @@ var count = 0; // # of replacements made

// replacement, to the result
res += str.substring(pos, nextIndex) + new_; // Increment our pointer in the src string
res += str.substring(pos, nextIndex) + new_;
// Increment our pointer in the src string
pos = nextIndex + old.length;
count++; // See if there are any more replacements to be made
count++;
// See if there are any more replacements to be made
nextIndex = str.indexOf(old, pos);
}
nextIndex = str.indexOf(old, pos);
} // We've either reached the end, or done the max # of
// We've either reached the end, or done the max # of
// replacements, tack on any remaining string
if (pos < str.length) {
res += str.substring(pos);
}
return r.copySafeness(originalStr, res);
}
_exports.replace = replace;
function reverse(val) {
var arr;
if (lib.isString(val)) {

@@ -437,14 +355,9 @@ arr = list(val);

}
arr.reverse();
if (lib.isString(val)) {
return r.copySafeness(val, arr.join(''));
}
return arr;
}
_exports.reverse = reverse;
function round(val, precision, method) {

@@ -454,3 +367,2 @@ precision = precision || 0;

var rounder;
if (method === 'ceil') {

@@ -463,8 +375,5 @@ rounder = Math.ceil;

}
return rounder(val * factor) / factor;
}
_exports.round = round;
function slice(arr, slices, fillWith) {

@@ -475,25 +384,17 @@ var sliceLength = Math.floor(arr.length / slices);

var offset = 0;
for (var i = 0; i < slices; i++) {
var start = offset + i * sliceLength;
if (i < extra) {
offset++;
}
var end = offset + (i + 1) * sliceLength;
var currSlice = arr.slice(start, end);
if (fillWith && i >= extra) {
currSlice.push(fillWith);
}
res.push(currSlice);
}
return res;
}
_exports.slice = slice;
function sum(arr, attr, start) {

@@ -503,3 +404,2 @@ if (start === void 0) {

}
if (attr) {

@@ -510,3 +410,2 @@ arr = lib.map(arr, function (v) {

}
return start + arr.reduce(function (a, b) {

@@ -516,7 +415,5 @@ return a + b;

}
_exports.sum = sum;
_exports.sort = r.makeMacro(['value', 'reverse', 'case_sensitive', 'attribute'], [], function sortFilter(arr, reversed, caseSens, attr) {
var _this = this;
// Copy it

@@ -530,7 +427,5 @@ var array = lib.map(arr, function (v) {

var y = attr ? getAttribute(b) : b;
if (_this.env.opts.throwOnUndefined && attr && (x === undefined || y === undefined)) {
throw new TypeError("sort: attribute \"" + attr + "\" resolved to undefined");
}
if (!caseSens && lib.isString(x) && lib.isString(y)) {

@@ -540,3 +435,2 @@ x = x.toLowerCase();

}
if (x < y) {

@@ -552,9 +446,6 @@ return reversed ? 1 : -1;

});
function string(obj) {
return r.copySafeness(obj, obj);
}
_exports.string = string;
function striptags(input, preserveLinebreaks) {

@@ -565,3 +456,2 @@ input = normalize(input, '');

var res = '';
if (preserveLinebreaks) {

@@ -575,8 +465,5 @@ res = trimmedInput.replace(/^ +| +$/gm, '') // remove leading and trailing spaces

}
return r.copySafeness(input, res);
}
_exports.striptags = striptags;
function title(str) {

@@ -589,11 +476,7 @@ str = normalize(str, '');

}
_exports.title = title;
function trim(str) {
return r.copySafeness(str, str.replace(/^\s*|\s*$/g, ''));
}
_exports.trim = trim;
function truncate(input, length, killwords, end) {

@@ -603,7 +486,5 @@ var orig = input;

length = length || 255;
if (input.length <= length) {
return input;
}
if (killwords) {

@@ -613,16 +494,11 @@ input = input.substring(0, length);

var idx = input.lastIndexOf(' ', length);
if (idx === -1) {
idx = length;
}
input = input.substring(0, idx);
}
input += end !== undefined && end !== null ? end : '...';
return r.copySafeness(orig, input);
}
_exports.truncate = truncate;
function upper(str) {

@@ -632,8 +508,5 @@ str = normalize(str, '');

}
_exports.upper = upper;
function urlencode(obj) {
var enc = encodeURIComponent;
if (lib.isString(obj)) {

@@ -645,3 +518,3 @@ return enc(obj);

var k = _ref2[0],
v = _ref2[1];
v = _ref2[1];
return enc(k) + "=" + enc(v);

@@ -651,8 +524,8 @@ }).join('&');

}
_exports.urlencode = urlencode;
_exports.urlencode = urlencode; // For the jinja regexp, see
// For the jinja regexp, see
// https://github.com/mitsuhiko/jinja2/blob/f15b814dcba6aa12bc74d1f7d0c881d55f7126be/jinja2/utils.py#L20-L23
var puncRe = /^(?:\(|<|&lt;)?(.*?)(?:\.|,|\)|\n|&gt;)?$/; // from http://blog.gerv.net/2011/05/html5_email_address_regexp/
var puncRe = /^(?:\(|<|&lt;)?(.*?)(?:\.|,|\)|\n|&gt;)?$/;
// from http://blog.gerv.net/2011/05/html5_email_address_regexp/
var emailRe = /^[\w.!#$%&'*+\-\/=?\^`{|}~]+@[a-z\d\-]+(\.[a-z\d\-]+)+$/i;

@@ -662,3 +535,2 @@ var httpHttpsRe = /^https?:\/\/.*$/;

var tldRe = /\.(?:org|net|com)(?:\:|\/|$)/;
function urlize(str, length, nofollow) {

@@ -668,3 +540,2 @@ if (isNaN(length)) {

}
var noFollowAttr = nofollow === true ? ' rel="nofollow"' : '';

@@ -678,23 +549,23 @@ var words = str.split(/(\s+)/).filter(function (word) {

var possibleUrl = matches ? matches[1] : word;
var shortUrl = possibleUrl.substr(0, length); // url that starts with http or https
var shortUrl = possibleUrl.substr(0, length);
// url that starts with http or https
if (httpHttpsRe.test(possibleUrl)) {
return "<a href=\"" + possibleUrl + "\"" + noFollowAttr + ">" + shortUrl + "</a>";
} // url that starts with www.
}
// url that starts with www.
if (wwwRe.test(possibleUrl)) {
return "<a href=\"http://" + possibleUrl + "\"" + noFollowAttr + ">" + shortUrl + "</a>";
} // an email address of the form username@domain.tld
}
// an email address of the form username@domain.tld
if (emailRe.test(possibleUrl)) {
return "<a href=\"mailto:" + possibleUrl + "\">" + possibleUrl + "</a>";
} // url that ends in .com, .org or .net that is not an email address
}
// url that ends in .com, .org or .net that is not an email address
if (tldRe.test(possibleUrl)) {
return "<a href=\"http://" + possibleUrl + "\"" + noFollowAttr + ">" + shortUrl + "</a>";
}
return word;

@@ -704,5 +575,3 @@ });

}
_exports.urlize = urlize;
function wordcount(str) {

@@ -713,5 +582,3 @@ str = normalize(str, '');

}
_exports.wordcount = wordcount;
function float(val, def) {

@@ -721,3 +588,2 @@ var res = parseFloat(val);

}
_exports.float = float;

@@ -728,9 +594,9 @@ var intFilter = r.makeMacro(['value', 'default', 'base'], [], function doInt(value, defaultValue, base) {

}
var res = parseInt(value, base);
return isNaN(res) ? defaultValue : res;
});
_exports.int = intFilter; // Aliases
_exports.int = intFilter;
// Aliases
_exports.d = _exports.default;
_exports.e = _exports.escape;

@@ -13,7 +13,5 @@ 'use strict';

index++;
if (index >= items.length) {
index = 0;
}
this.current = items[index];

@@ -24,3 +22,2 @@ return this.current;

}
function _joiner(sep) {

@@ -34,7 +31,7 @@ sep = sep || ',';

};
} // Making this a function instead so it returns a new object
}
// Making this a function instead so it returns a new object
// each time it's called. That way, if something like an environment
// uses it, they will each have their own copy.
function globals() {

@@ -50,5 +47,3 @@ return {

}
var arr = [];
if (step > 0) {

@@ -64,3 +59,2 @@ for (var i = start; i < stop; i += step) {

}
return arr;

@@ -76,3 +70,2 @@ },

}
module.exports = globals;

@@ -5,9 +5,10 @@ "use strict";

'use strict';
/* eslint-disable camelcase */
// This must be called like `nunjucks.installCompat` so that `this`
// references the nunjucks instance
var runtime = this.runtime;
var lib = this.lib; // Handle slim case where these 'modules' are excluded from the built source
var lib = this.lib;
// Handle slim case where these 'modules' are excluded from the built source
var Compiler = this.compiler.Compiler;

@@ -21,19 +22,14 @@ var Parser = this.parser.Parser;

var orig_Parser_parseAggregate;
if (Compiler) {
orig_Compiler_assertType = Compiler.prototype.assertType;
}
if (Parser) {
orig_Parser_parseAggregate = Parser.prototype.parseAggregate;
}
function uninstall() {
runtime.contextOrFrameLookup = orig_contextOrFrameLookup;
runtime.memberLookup = orig_memberLookup;
if (Compiler) {
Compiler.prototype.assertType = orig_Compiler_assertType;
}
if (Parser) {

@@ -43,20 +39,14 @@ Parser.prototype.parseAggregate = orig_Parser_parseAggregate;

}
runtime.contextOrFrameLookup = function contextOrFrameLookup(context, frame, key) {
var val = orig_contextOrFrameLookup.apply(this, arguments);
if (val !== undefined) {
return val;
}
switch (key) {
case 'True':
return true;
case 'False':
return false;
case 'None':
return null;
default:

@@ -66,3 +56,2 @@ return undefined;

};
function getTokensState(tokens) {

@@ -75,3 +64,2 @@ return {

}
if (process.env.BUILD_TYPE !== 'SLIM' && nodes && Compiler && Parser) {

@@ -88,3 +76,2 @@ // i.e., not slim mode

});
Compiler.prototype.assertType = function assertType(node) {

@@ -94,30 +81,19 @@ if (node instanceof Slice) {

}
orig_Compiler_assertType.apply(this, arguments);
};
Compiler.prototype.compileSlice = function compileSlice(node, frame) {
this._emit('(');
this._compileExpression(node.start, frame);
this._emit('),(');
this._compileExpression(node.stop, frame);
this._emit('),(');
this._compileExpression(node.step, frame);
this._emit(')');
};
Parser.prototype.parseAggregate = function parseAggregate() {
var _this = this;
var origState = getTokensState(this.tokens); // Set back one accounting for opening bracket/parens
var origState = getTokensState(this.tokens);
// Set back one accounting for opening bracket/parens
origState.colno--;
origState.index--;
try {

@@ -127,15 +103,11 @@ return orig_Parser_parseAggregate.apply(this);

var errState = getTokensState(this.tokens);
var rethrow = function rethrow() {
lib._assign(_this.tokens, errState);
return e;
}; // Reset to state before original parseAggregate called
};
// Reset to state before original parseAggregate called
lib._assign(this.tokens, origState);
this.peeked = false;
var tok = this.peekToken();
if (tok.type !== lexer.TOKEN_LEFT_BRACKET) {

@@ -146,8 +118,7 @@ throw rethrow();

}
var node = new Slice(tok.lineno, tok.colno);
var node = new Slice(tok.lineno, tok.colno); // If we don't encounter a colon while parsing, this is not a slice,
// If we don't encounter a colon while parsing, this is not a slice,
// so re-raise the original exception.
var isSlice = false;
for (var i = 0; i <= node.fields.length; i++) {

@@ -157,3 +128,2 @@ if (this.skip(lexer.TOKEN_RIGHT_BRACKET)) {

}
if (i === node.fields.length) {

@@ -166,3 +136,2 @@ if (isSlice) {

}
if (this.skip(lexer.TOKEN_COLON)) {

@@ -176,7 +145,5 @@ isSlice = true;

}
if (!isSlice) {
throw rethrow();
}
return new nodes.Array(tok.lineno, tok.colno, [node]);

@@ -186,10 +153,7 @@ }

}
function sliceLookup(obj, start, stop, step) {
obj = obj || [];
if (start === null) {
start = step < 0 ? obj.length - 1 : 0;
}
if (stop === null) {

@@ -200,9 +164,6 @@ stop = step < 0 ? -1 : obj.length;

}
if (start < 0) {
start += obj.length;
}
var results = [];
for (var i = start;; i += step) {

@@ -212,21 +173,15 @@ if (i < 0 || i > obj.length) {

}
if (step > 0 && i >= stop) {
break;
}
if (step < 0 && i <= stop) {
break;
}
results.push(runtime.memberLookup(obj, i));
}
return results;
}
function hasOwnProp(obj, key) {
return Object.prototype.hasOwnProperty.call(obj, key);
}
var ARRAY_MEMBERS = {

@@ -237,7 +192,5 @@ pop: function pop(index) {

}
if (index >= this.length || index < 0) {
throw new Error('KeyError');
}
return this.splice(index, 1);

@@ -254,3 +207,2 @@ },

}
throw new Error('ValueError');

@@ -260,3 +212,2 @@ },

var count = 0;
for (var i = 0; i < this.length; i++) {

@@ -267,3 +218,2 @@ if (this[i] === element) {

}
return count;

@@ -273,7 +223,5 @@ },

var i;
if ((i = this.indexOf(element)) === -1) {
throw new Error('ValueError');
}
return i;

@@ -300,7 +248,5 @@ },

var output = this[key];
if (output === undefined) {
output = def;
}
return output;

@@ -313,3 +259,2 @@ },

var output = this[key];
if (output === undefined && def !== undefined) {

@@ -322,3 +267,2 @@ output = def;

}
return output;

@@ -328,7 +272,5 @@ },

var keys = lib.keys(this);
if (!keys.length) {
throw new Error('KeyError');
}
var k = keys[0];

@@ -343,7 +285,5 @@ var val = this[k];

}
if (!(key in this)) {
this[key] = def;
}
return this[key];

@@ -353,10 +293,9 @@ },

lib._assign(this, kwargs);
return null; // Always returns None
}
};
OBJECT_MEMBERS.iteritems = OBJECT_MEMBERS.items;
OBJECT_MEMBERS.itervalues = OBJECT_MEMBERS.values;
OBJECT_MEMBERS.iterkeys = OBJECT_MEMBERS.keys;
runtime.memberLookup = function memberLookup(obj, val, autoescape) {

@@ -366,20 +305,16 @@ if (arguments.length === 4) {

}
obj = obj || {};
obj = obj || {}; // If the object is an object, return any of the methods that Python would
// If the object is an object, return any of the methods that Python would
// otherwise provide.
if (lib.isArray(obj) && hasOwnProp(ARRAY_MEMBERS, val)) {
return ARRAY_MEMBERS[val].bind(obj);
}
if (lib.isObject(obj) && hasOwnProp(OBJECT_MEMBERS, val)) {
return OBJECT_MEMBERS[val].bind(obj);
}
return orig_memberLookup.apply(this, arguments);
};
return uninstall;
}
module.exports = installCompat;
'use strict';
var lib = require('./lib');
var whitespaceChars = " \n\t\r\xA0";

@@ -40,3 +39,2 @@ var delimChars = '()[]{}%*-+~/#,:|.<>=!';

var TOKEN_REGEX = 'regex';
function token(type, value, lineno, colno) {

@@ -50,3 +48,2 @@ return {

}
var Tokenizer = /*#__PURE__*/function () {

@@ -73,5 +70,3 @@ function Tokenizer(str, opts) {

}
var _proto = Tokenizer.prototype;
_proto.nextToken = function nextToken() {

@@ -81,7 +76,5 @@ var lineno = this.lineno;

var tok;
if (this.in_code) {
// Otherwise, if we are in a block parse it as code
var cur = this.current();
if (this.isFinished()) {

@@ -104,6 +97,4 @@ // We have nothing else to parse

this.in_code = false;
if (this.trimBlocks) {
cur = this.current();
if (cur === '\n') {

@@ -116,3 +107,2 @@ // Skip newline

cur = this.current();
if (cur === '\n') {

@@ -126,3 +116,2 @@ this.forward();

}
return token(TOKEN_BLOCK_END, tok, lineno, colno);

@@ -135,6 +124,6 @@ } else if ((tok = this._extractString(this.tags.VARIABLE_END)) || (tok = this._extractString('-' + this.tags.VARIABLE_END))) {

// Skip past 'r/'.
this.forwardN(2); // Extract until the end of the regex -- / ends it, \/ does not.
this.forwardN(2);
// Extract until the end of the regex -- / ends it, \/ does not.
var regexBody = '';
while (!this.isFinished()) {

@@ -148,12 +137,10 @@ if (this.current() === '/' && this.previous() !== '\\') {

}
} // Check for flags.
}
// Check for flags.
// The possible flags are according to https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/RegExp)
var POSSIBLE_FLAGS = ['g', 'i', 'm', 'y'];
var regexFlags = '';
while (!this.isFinished()) {
var isCurrentAFlag = POSSIBLE_FLAGS.indexOf(this.current()) !== -1;
if (isCurrentAFlag) {

@@ -166,3 +153,2 @@ regexFlags += this.current();

}
return token(TOKEN_REGEX, {

@@ -178,7 +164,7 @@ body: regexBody,

var type;
if (lib.indexOf(complexOps, curComplex) !== -1) {
this.forward();
cur = curComplex; // See if this is a strict equality/inequality comparator
cur = curComplex;
// See if this is a strict equality/inequality comparator
if (lib.indexOf(complexOps, curComplex + this.current()) !== -1) {

@@ -189,3 +175,2 @@ cur = curComplex + this.current();

}
switch (cur) {

@@ -195,43 +180,32 @@ case '(':

break;
case ')':
type = TOKEN_RIGHT_PAREN;
break;
case '[':
type = TOKEN_LEFT_BRACKET;
break;
case ']':
type = TOKEN_RIGHT_BRACKET;
break;
case '{':
type = TOKEN_LEFT_CURLY;
break;
case '}':
type = TOKEN_RIGHT_CURLY;
break;
case ',':
type = TOKEN_COMMA;
break;
case ':':
type = TOKEN_COLON;
break;
case '~':
type = TOKEN_TILDE;
break;
case '|':
type = TOKEN_PIPE;
break;
default:
type = TOKEN_OPERATOR;
}
return token(type, cur, lineno, colno);

@@ -242,9 +216,6 @@ } else {

tok = this._extractUntil(whitespaceChars + delimChars);
if (tok.match(/^[-+]?[0-9]+$/)) {
if (this.current() === '.') {
this.forward();
var dec = this._extract(intChars);
return token(TOKEN_FLOAT, tok + '.' + dec, lineno, colno);

@@ -278,3 +249,2 @@ } else {

var beginChars = this.tags.BLOCK_START.charAt(0) + this.tags.VARIABLE_START.charAt(0) + this.tags.COMMENT_START.charAt(0) + this.tags.COMMENT_END.charAt(0);
if (this.isFinished()) {

@@ -292,7 +262,8 @@ return null;

var inComment = false;
if (this._matches(this.tags.COMMENT_START)) {
inComment = true;
tok = this._extractString(this.tags.COMMENT_START);
} // Continually consume text, breaking on the tag delimiter
}
// Continually consume text, breaking on the tag delimiter
// characters and checking to see if it's a start tag.

@@ -303,15 +274,10 @@ //

// _extractUntil
while ((data = this._extractUntil(beginChars)) !== null) {
tok += data;
if ((this._matches(this.tags.BLOCK_START) || this._matches(this.tags.VARIABLE_START) || this._matches(this.tags.COMMENT_START)) && !inComment) {
if (this.lstripBlocks && this._matches(this.tags.BLOCK_START) && this.colno > 0 && this.colno <= tok.length) {
var lastLine = tok.slice(-this.colno);
if (/^\s+$/.test(lastLine)) {
// Remove block leading whitespace from beginning of the string
tok = tok.slice(0, -this.colno);
if (!tok.length) {

@@ -323,5 +289,4 @@ // All data removed, collapse to avoid unnecessary nodes

}
} // If it is a start tag, stop looping
}
// If it is a start tag, stop looping
break;

@@ -332,3 +297,2 @@ } else if (this._matches(this.tags.COMMENT_END)) {

}
tok += this._extractString(this.tags.COMMENT_END);

@@ -343,7 +307,5 @@ break;

}
if (data === null && inComment) {
throw new Error('expected end of comment, got end of file');
}
return token(inComment ? TOKEN_COMMENT : TOKEN_DATA, tok, lineno, colno);

@@ -353,13 +315,9 @@ }

};
_proto._parseString = function _parseString(delimiter) {
this.forward();
var str = '';
while (!this.isFinished() && this.current() !== delimiter) {
var cur = this.current();
if (cur === '\\') {
this.forward();
switch (this.current()) {

@@ -369,15 +327,11 @@ case 'n':

break;
case 't':
str += '\t';
break;
case 'r':
str += '\r';
break;
default:
str += this.current();
}
this.forward();

@@ -389,7 +343,5 @@ } else {

}
this.forward();
return str;
};
_proto._matches = function _matches(str) {

@@ -399,7 +351,5 @@ if (this.index + str.length > this.len) {

}
var m = this.str.slice(this.index, this.index + str.length);
return m === str;
};
_proto._extractString = function _extractString(str) {

@@ -410,6 +360,4 @@ if (this._matches(str)) {

}
return null;
};
_proto._extractUntil = function _extractUntil(charString) {

@@ -420,3 +368,2 @@ // Extract all non-matching chars, with the default matching set

};
_proto._extract = function _extract(charString) {

@@ -427,3 +374,2 @@ // Extract all matching chars (no default, so charString must be

};
_proto._extractMatching = function _extractMatching(breakOnMatch, charString) {

@@ -433,15 +379,16 @@ // Pull out characters until a breaking char is hit.

// If breakOnMatch is true, a matching char stops it.
if (this.isFinished()) {
return null;
}
var first = charString.indexOf(this.current());
var first = charString.indexOf(this.current()); // Only proceed if the first character doesn't meet our condition
// Only proceed if the first character doesn't meet our condition
if (breakOnMatch && first === -1 || !breakOnMatch && first !== -1) {
var t = this.current();
this.forward(); // And pull out all the chars one at a time until we hit a
this.forward();
// And pull out all the chars one at a time until we hit a
// breaking char
var idx = charString.indexOf(this.current());
while ((breakOnMatch && idx === -1 || !breakOnMatch && idx !== -1) && !this.isFinished()) {

@@ -452,25 +399,19 @@ t += this.current();

}
return t;
}
return '';
};
_proto._extractRegex = function _extractRegex(regex) {
var matches = this.currentStr().match(regex);
if (!matches) {
return null;
} // Move forward whatever was matched
}
// Move forward whatever was matched
this.forwardN(matches[0].length);
return matches;
};
_proto.isFinished = function isFinished() {
return this.index >= this.len;
};
_proto.forwardN = function forwardN(n) {

@@ -481,6 +422,4 @@ for (var i = 0; i < n; i++) {

};
_proto.forward = function forward() {
this.index++;
if (this.previous() === '\n') {

@@ -493,3 +432,2 @@ this.lineno++;

};
_proto.backN = function backN(n) {

@@ -500,10 +438,7 @@ for (var i = 0; i < n; i++) {

};
_proto.back = function back() {
this.index--;
if (this.current() === '\n') {
this.lineno--;
var idx = this.src.lastIndexOf('\n', this.index - 1);
if (idx === -1) {

@@ -517,5 +452,6 @@ this.colno = this.index;

}
} // current returns current character
}
// current returns current character
;
_proto.current = function current() {

@@ -525,7 +461,7 @@ if (!this.isFinished()) {

}
return '';
}
return '';
} // currentStr returns what's left of the unparsed string
// currentStr returns what's left of the unparsed string
;
_proto.currentStr = function currentStr() {

@@ -535,13 +471,9 @@ if (!this.isFinished()) {

}
return '';
};
_proto.previous = function previous() {
return this.str.charAt(this.index - 1);
};
return Tokenizer;
}();
module.exports = {

@@ -548,0 +480,0 @@ lex: function lex(src, opts) {

@@ -10,18 +10,14 @@ 'use strict';

'<': '&lt;',
'>': '&gt;'
'>': '&gt;',
'\\': '&#92;'
};
var escapeRegex = /[&"'<>]/g;
var escapeRegex = /[&"'<>\\]/g;
var _exports = module.exports = {};
function hasOwnProp(obj, k) {
return ObjProto.hasOwnProperty.call(obj, k);
}
_exports.hasOwnProp = hasOwnProp;
function lookupEscape(ch) {
return escapeMap[ch];
}
function _prettifyError(path, withInternals, err) {

@@ -32,5 +28,5 @@ if (!err.Update) {

}
err.Update(path);
err.Update(path); // Unless they marked the dev flag, show them a trace from here
// Unless they marked the dev flag, show them a trace from here
if (!withInternals) {

@@ -41,12 +37,8 @@ var old = err;

}
return err;
}
_exports._prettifyError = _prettifyError;
function TemplateError(message, lineno, colno) {
var err;
var cause;
if (message instanceof Error) {

@@ -56,3 +48,2 @@ cause = message;

}
if (Object.setPrototypeOf) {

@@ -69,20 +60,14 @@ err = new Error(message);

}
Object.defineProperty(err, 'name', {
value: 'Template render error'
});
if (Error.captureStackTrace) {
Error.captureStackTrace(err, this.constructor);
}
var getStack;
if (cause) {
var stackDescriptor = Object.getOwnPropertyDescriptor(cause, 'stack');
getStack = stackDescriptor && (stackDescriptor.get || function () {
return stackDescriptor.value;
});
if (!getStack) {

@@ -95,3 +80,2 @@ getStack = function getStack() {

var stack = new Error(message).stack;
getStack = function getStack() {

@@ -101,3 +85,2 @@ return stack;

}
Object.defineProperty(err, 'stack', {

@@ -114,7 +97,7 @@ get: function get() {

err.firstUpdate = true;
err.Update = function Update(path) {
var msg = '(' + (path || 'unknown path') + ')';
err.Update = function Update(path) {
var msg = '(' + (path || 'unknown path') + ')'; // only show lineno + colno next to path of template
// only show lineno + colno next to path of template
// where error occurred
if (this.firstUpdate) {

@@ -127,9 +110,6 @@ if (this.lineno && this.colno) {

}
msg += '\n ';
if (this.firstUpdate) {
msg += ' ';
}
this.message = msg + (this.message || '');

@@ -139,6 +119,4 @@ this.firstUpdate = false;

};
return err;
}
if (Object.setPrototypeOf) {

@@ -153,34 +131,24 @@ Object.setPrototypeOf(TemplateError.prototype, Error.prototype);

}
_exports.TemplateError = TemplateError;
function escape(val) {
return val.replace(escapeRegex, lookupEscape);
}
_exports.escape = escape;
function isFunction(obj) {
return ObjProto.toString.call(obj) === '[object Function]';
}
_exports.isFunction = isFunction;
function isArray(obj) {
return ObjProto.toString.call(obj) === '[object Array]';
}
_exports.isArray = isArray;
function isString(obj) {
return ObjProto.toString.call(obj) === '[object String]';
}
_exports.isString = isString;
function isObject(obj) {
return ObjProto.toString.call(obj) === '[object Object]';
}
_exports.isObject = isObject;
_exports.isObject = isObject;
/**

@@ -191,3 +159,2 @@ * @param {string|number} attr

*/
function _prepareAttributeParts(attr) {

@@ -197,9 +164,8 @@ if (!attr) {

}
if (typeof attr === 'string') {
return attr.split('.');
}
return [attr];
}
/**

@@ -209,14 +175,11 @@ * @param {string} attribute Attribute value. Dots allowed.

*/
function getAttrGetter(attribute) {
var parts = _prepareAttributeParts(attribute);
return function attrGetter(item) {
var _item = item;
for (var i = 0; i < parts.length; i++) {
var part = parts[i];
for (var i = 0; i < parts.length; i++) {
var part = parts[i]; // If item is not an object, and we still got parts to handle, it means
// If item is not an object, and we still got parts to handle, it means
// that something goes wrong. Just roll out to undefined in that case.
if (hasOwnProp(_item, part)) {

@@ -228,46 +191,32 @@ _item = _item[part];

}
return _item;
};
}
_exports.getAttrGetter = getAttrGetter;
function groupBy(obj, val, throwOnUndefined) {
var result = {};
var iterator = isFunction(val) ? val : getAttrGetter(val);
for (var i = 0; i < obj.length; i++) {
var value = obj[i];
var key = iterator(value, i);
if (key === undefined && throwOnUndefined === true) {
throw new TypeError("groupby: attribute \"" + val + "\" resolved to undefined");
}
(result[key] || (result[key] = [])).push(value);
}
return result;
}
_exports.groupBy = groupBy;
function toArray(obj) {
return Array.prototype.slice.call(obj);
}
_exports.toArray = toArray;
function without(array) {
var result = [];
if (!array) {
return result;
}
var length = array.length;
var contains = toArray(arguments).slice(1);
var index = -1;
while (++index < length) {

@@ -278,20 +227,13 @@ if (indexOf(contains, array[index]) === -1) {

}
return result;
}
_exports.without = without;
function repeat(char_, n) {
var str = '';
for (var i = 0; i < n; i++) {
str += char_;
}
return str;
}
_exports.repeat = repeat;
function each(obj, func, context) {

@@ -301,3 +243,2 @@ if (obj == null) {

}
if (ArrayProto.forEach && obj.forEach === ArrayProto.forEach) {

@@ -311,35 +252,24 @@ obj.forEach(func, context);

}
_exports.each = each;
function map(obj, func) {
var results = [];
if (obj == null) {
return results;
}
if (ArrayProto.map && obj.map === ArrayProto.map) {
return obj.map(func);
}
for (var i = 0; i < obj.length; i++) {
results[results.length] = func(obj[i], i);
}
if (obj.length === +obj.length) {
results.length = obj.length;
}
return results;
}
_exports.map = map;
function asyncIter(arr, iter, cb) {
var i = -1;
function next() {
i++;
if (i < arr.length) {

@@ -351,8 +281,5 @@ iter(arr[i], i, next, cb);

}
next();
}
_exports.asyncIter = asyncIter;
function asyncFor(obj, iter, cb) {

@@ -362,7 +289,5 @@ var keys = keys_(obj || {});

var i = -1;
function next() {
i++;
var k = keys[i];
if (i < len) {

@@ -374,18 +299,12 @@ iter(k, obj[k], i, len, next);

}
next();
}
_exports.asyncFor = asyncFor;
function indexOf(arr, searchElement, fromIndex) {
return Array.prototype.indexOf.call(arr || [], searchElement, fromIndex);
}
_exports.indexOf = indexOf;
function keys_(obj) {
/* eslint-disable no-restricted-syntax */
var arr = [];
for (var k in obj) {

@@ -396,8 +315,5 @@ if (hasOwnProp(obj, k)) {

}
return arr;
}
_exports.keys = keys_;
function _entries(obj) {

@@ -408,5 +324,3 @@ return keys_(obj).map(function (k) {

}
_exports._entries = _entries;
function _values(obj) {

@@ -417,5 +331,3 @@ return keys_(obj).map(function (k) {

}
_exports._values = _values;
function extend(obj1, obj2) {

@@ -428,5 +340,3 @@ obj1 = obj1 || {};

}
_exports._assign = _exports.extend = extend;
function inOperator(key, val) {

@@ -438,6 +348,4 @@ if (isArray(val) || isString(val)) {

}
throw new Error('Cannot use "in" operator to search for "' + key + '" in unexpected types.');
}
_exports.inOperator = inOperator;
'use strict';
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var path = require('path');
var _require = require('./object'),
EmitterObj = _require.EmitterObj;
EmitterObj = _require.EmitterObj;
module.exports = /*#__PURE__*/function (_EmitterObj) {
_inheritsLoose(Loader, _EmitterObj);
function Loader() {
return _EmitterObj.apply(this, arguments) || this;
}
var _proto = Loader.prototype;
_proto.resolve = function resolve(from, to) {
return path.resolve(path.dirname(from), to);
};
_proto.isRelative = function isRelative(filename) {
return filename.indexOf('./') === 0 || filename.indexOf('../') === 0;
};
return Loader;
}(EmitterObj);
/* eslint-disable no-console */
'use strict';
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var fs = require('fs');
var path = require('path');
var Loader = require('./loader');
var _require = require('./precompiled-loader.js'),
PrecompiledLoader = _require.PrecompiledLoader;
PrecompiledLoader = _require.PrecompiledLoader;
var chokidar;
var FileSystemLoader = /*#__PURE__*/function (_Loader) {
_inheritsLoose(FileSystemLoader, _Loader);
function FileSystemLoader(searchPaths, opts) {
var _this;
_this = _Loader.call(this) || this;
if (typeof opts === 'boolean') {
console.log('[nunjucks] Warning: you passed a boolean as the second ' + 'argument to FileSystemLoader, but it now takes an options ' + 'object. See http://mozilla.github.io/nunjucks/api.html#filesystemloader');
}
opts = opts || {};
_this.pathsToNames = {};
_this.noCache = !!opts.noCache;
if (searchPaths) {
searchPaths = Array.isArray(searchPaths) ? searchPaths : [searchPaths]; // For windows, convert to forward slashes
searchPaths = Array.isArray(searchPaths) ? searchPaths : [searchPaths];
// For windows, convert to forward slashes
_this.searchPaths = searchPaths.map(path.normalize);

@@ -42,3 +31,2 @@ } else {

}
if (opts.watch) {

@@ -52,9 +40,6 @@ // Watch all the templates in the paths and fire an event when

}
var paths = _this.searchPaths.filter(fs.existsSync);
var watcher = chokidar.watch(paths);
watcher.on('all', function (event, fullname) {
fullname = path.resolve(fullname);
if (event === 'change' && fullname in _this.pathsToNames) {

@@ -68,17 +53,14 @@ _this.emit('update', _this.pathsToNames[fullname], fullname);

}
return _this;
}
var _proto = FileSystemLoader.prototype;
_proto.getSource = function getSource(name) {
var fullpath = null;
var paths = this.searchPaths;
for (var i = 0; i < paths.length; i++) {
var basePath = path.resolve(paths[i]);
var p = path.resolve(paths[i], name); // Only allow the current directory and anything
var p = path.resolve(paths[i], name);
// Only allow the current directory and anything
// underneath it to be searched
if (p.indexOf(basePath) === 0 && fs.existsSync(p)) {

@@ -89,7 +71,5 @@ fullpath = p;

}
if (!fullpath) {
return null;
}
this.pathsToNames[fullpath] = name;

@@ -104,12 +84,8 @@ var source = {

};
return FileSystemLoader;
}(Loader);
var NodeResolveLoader = /*#__PURE__*/function (_Loader2) {
_inheritsLoose(NodeResolveLoader, _Loader2);
function NodeResolveLoader(opts) {
var _this2;
_this2 = _Loader2.call(this) || this;

@@ -119,3 +95,2 @@ opts = opts || {};

_this2.noCache = !!opts.noCache;
if (opts.watch) {

@@ -127,13 +102,9 @@ try {

}
_this2.watcher = chokidar.watch();
_this2.watcher.on('change', function (fullname) {
_this2.emit('update', _this2.pathsToNames[fullname], fullname);
});
_this2.watcher.on('error', function (error) {
console.log('Watcher error: ' + error);
});
_this2.on('load', function (name, source) {

@@ -143,8 +114,5 @@ _this2.watcher.add(source.path);

}
return _this2;
}
var _proto2 = NodeResolveLoader.prototype;
_proto2.getSource = function getSource(name) {

@@ -155,9 +123,6 @@ // Don't allow file-system traversal

}
if (/^[A-Z]:/.test(name)) {
return null;
}
var fullpath;
try {

@@ -168,3 +133,2 @@ fullpath = require.resolve(name);

}
this.pathsToNames[fullpath] = name;

@@ -179,6 +143,4 @@ var source = {

};
return NodeResolveLoader;
}(Loader);
module.exports = {

@@ -185,0 +147,0 @@ FileSystemLoader: FileSystemLoader,

'use strict';
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var _require = require('./object'),
Obj = _require.Obj;
Obj = _require.Obj;
function traverseAndCheck(obj, type, results) {

@@ -18,3 +15,2 @@ if (obj instanceof type) {

}
if (obj instanceof Node) {

@@ -24,20 +20,14 @@ obj.findAll(type, results);

}
var Node = /*#__PURE__*/function (_Obj) {
_inheritsLoose(Node, _Obj);
function Node() {
return _Obj.apply(this, arguments) || this;
}
var _proto = Node.prototype;
_proto.init = function init(lineno, colno) {
var _arguments = arguments,
_this = this;
_this = this;
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
this.lineno = lineno;

@@ -47,18 +37,15 @@ this.colno = colno;

// The first two args are line/col numbers, so offset by 2
var val = _arguments[i + 2]; // Fields should never be undefined, but null. It makes
var val = _arguments[i + 2];
// Fields should never be undefined, but null. It makes
// testing easier to normalize values.
if (val === undefined) {
val = null;
}
_this[field] = val;
});
};
_proto.findAll = function findAll(type, results) {
var _this2 = this;
results = results || [];
if (this instanceof NodeList) {

@@ -73,9 +60,6 @@ this.children.forEach(function (child) {

}
return results;
};
_proto.iterFields = function iterFields(func) {
var _this3 = this;
this.fields.forEach(function (field) {

@@ -85,14 +69,9 @@ func(_this3[field], field);

};
return Node;
}(Obj); // Abstract nodes
var Value = /*#__PURE__*/function (_Node) {
_inheritsLoose(Value, _Node);
function Value() {
return _Node.apply(this, arguments) || this;
}
_createClass(Value, [{

@@ -109,24 +88,16 @@ key: "typename",

}]);
return Value;
}(Node); // Concrete nodes
var NodeList = /*#__PURE__*/function (_Node2) {
_inheritsLoose(NodeList, _Node2);
function NodeList() {
return _Node2.apply(this, arguments) || this;
}
var _proto2 = NodeList.prototype;
_proto2.init = function init(lineno, colno, nodes) {
_Node2.prototype.init.call(this, lineno, colno, nodes || []);
};
_proto2.addChild = function addChild(node) {
this.children.push(node);
};
_createClass(NodeList, [{

@@ -143,9 +114,7 @@ key: "typename",

}]);
return NodeList;
}(Node);
var Root = NodeList.extend('Root');
var Literal = Value.extend('Literal');
var Symbol = Value.extend('Symbol');
var _Symbol = Value.extend('Symbol');
var Group = NodeList.extend('Group');

@@ -179,16 +148,11 @@ var ArrayNode = NodeList.extend('Array');

});
var FromImport = /*#__PURE__*/function (_Node3) {
_inheritsLoose(FromImport, _Node3);
function FromImport() {
return _Node3.apply(this, arguments) || this;
}
var _proto3 = FromImport.prototype;
_proto3.init = function init(lineno, colno, template, names, withContext) {
_Node3.prototype.init.call(this, lineno, colno, template, names || new NodeList(), withContext);
};
_createClass(FromImport, [{

@@ -205,6 +169,4 @@ key: "typename",

}]);
return FromImport;
}(Node);
var FunCall = Node.extend('FunCall', {

@@ -283,4 +245,5 @@ fields: ['name', 'args']

});
var CallExtensionAsync = CallExtension.extend('CallExtensionAsync'); // This is hacky, but this is just a debugging function anyway
var CallExtensionAsync = CallExtension.extend('CallExtensionAsync');
// This is hacky, but this is just a debugging function anyway
function print(str, indent, inline) {

@@ -292,13 +255,11 @@ var lines = str.split('\n');

}
var nl = i === lines.length - 1 ? '' : '\n';
process.stdout.write("" + line + nl);
});
} // Print the AST in a nicely formatted tree format for debuggin
}
// Print the AST in a nicely formatted tree format for debuggin
function printNodes(node, indent) {
indent = indent || 0;
print(node.typename + ': ', indent);
if (node instanceof NodeList) {

@@ -311,7 +272,5 @@ print('\n');

print(node.extName + "." + node.prop + "\n");
if (node.args) {
printNodes(node.args, indent + 2);
}
if (node.contentArgs) {

@@ -333,3 +292,2 @@ node.contentArgs.forEach(function (n) {

});
if (props) {

@@ -340,6 +298,5 @@ print(JSON.stringify(props, null, 2) + '\n', null, true);

}
nodes.forEach(function (_ref) {
var fieldName = _ref[0],
n = _ref[1];
n = _ref[1];
print("[" + fieldName + "] =>", indent + 2);

@@ -350,3 +307,2 @@ printNodes(n, indent + 4);

}
module.exports = {

@@ -358,3 +314,3 @@ Node: Node,

Literal: Literal,
Symbol: Symbol,
Symbol: _Symbol,
Group: Group,

@@ -361,0 +317,0 @@ Array: ArrayNode,

@@ -1,15 +0,12 @@

'use strict'; // A simple class system, more documentation to come
'use strict';
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
// A simple class system, more documentation to come
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var EventEmitter = require('events');
var lib = require('./lib');
function parentWrap(parent, prop) {

@@ -19,7 +16,7 @@ if (typeof parent !== 'function' || typeof prop !== 'function') {

}
return function wrap() {
// Save the current parent method
var tmp = this.parent; // Set parent to the previous method, call, and restore
var tmp = this.parent;
// Set parent to the previous method, call, and restore
this.parent = parent;

@@ -31,3 +28,2 @@ var res = prop.apply(this, arguments);

}
function extendClass(cls, name, props) {

@@ -38,10 +34,7 @@ props = props || {};

});
var subclass = /*#__PURE__*/function (_cls) {
_inheritsLoose(subclass, _cls);
function subclass() {
return _cls.apply(this, arguments) || this;
}
_createClass(subclass, [{

@@ -53,11 +46,7 @@ key: "typename",

}]);
return subclass;
}(cls);
lib._assign(subclass.prototype, props);
return subclass;
}
var Obj = /*#__PURE__*/function () {

@@ -68,7 +57,4 @@ function Obj() {

}
var _proto = Obj.prototype;
_proto.init = function init() {};
Obj.extend = function extend(name, props) {

@@ -79,6 +65,4 @@ if (typeof name === 'object') {

}
return extendClass(this, name, props);
};
_createClass(Obj, [{

@@ -90,25 +74,16 @@ key: "typename",

}]);
return Obj;
}();
var EmitterObj = /*#__PURE__*/function (_EventEmitter) {
_inheritsLoose(EmitterObj, _EventEmitter);
function EmitterObj() {
var _this2;
var _this;
_this = _EventEmitter.call(this) || this; // Unfortunately necessary for backwards compatibility
_this = _EventEmitter.call(this) || this;
// Unfortunately necessary for backwards compatibility
(_this2 = _this).init.apply(_this2, arguments);
return _this;
}
var _proto2 = EmitterObj.prototype;
_proto2.init = function init() {};
EmitterObj.extend = function extend(name, props) {

@@ -119,6 +94,4 @@ if (typeof name === 'object') {

}
return extendClass(this, name, props);
};
_createClass(EmitterObj, [{

@@ -130,6 +103,4 @@ key: "typename",

}]);
return EmitterObj;
}(EventEmitter);
module.exports = {

@@ -136,0 +107,0 @@ Obj: Obj,

'use strict';
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var lexer = require('./lexer');
var nodes = require('./nodes');
var Obj = require('./object').Obj;
var lib = require('./lib');
var Parser = /*#__PURE__*/function (_Obj) {
_inheritsLoose(Parser, _Obj);
function Parser() {
return _Obj.apply(this, arguments) || this;
}
var _proto = Parser.prototype;
_proto.init = function init(tokens) {

@@ -31,6 +22,4 @@ this.tokens = tokens;

};
_proto.nextToken = function nextToken(withWhitespace) {
var tok;
if (this.peeked) {

@@ -45,5 +34,3 @@ if (!withWhitespace && this.peeked.type === lexer.TOKEN_WHITESPACE) {

}
tok = this.tokens.nextToken();
if (!withWhitespace) {

@@ -54,6 +41,4 @@ while (tok && tok.type === lexer.TOKEN_WHITESPACE) {

}
return tok;
};
_proto.peekToken = function peekToken() {

@@ -63,3 +48,2 @@ this.peeked = this.peeked || this.nextToken();

};
_proto.pushToken = function pushToken(tok) {

@@ -69,6 +53,4 @@ if (this.peeked) {

}
this.peeked = tok;
};
_proto.error = function error(msg, lineno, colno) {

@@ -80,21 +62,15 @@ if (lineno === undefined || colno === undefined) {

}
if (lineno !== undefined) {
lineno += 1;
}
if (colno !== undefined) {
colno += 1;
}
return new lib.TemplateError(msg, lineno, colno);
};
_proto.fail = function fail(msg, lineno, colno) {
throw this.error(msg, lineno, colno);
};
_proto.skip = function skip(type) {
var tok = this.nextToken();
if (!tok || tok.type !== type) {

@@ -104,19 +80,13 @@ this.pushToken(tok);

}
return true;
};
_proto.expect = function expect(type) {
var tok = this.nextToken();
if (tok.type !== type) {
this.fail('expected ' + type + ', got ' + tok.type, tok.lineno, tok.colno);
}
return tok;
};
_proto.skipValue = function skipValue(type, val) {
var tok = this.nextToken();
if (!tok || tok.type !== type || tok.value !== val) {

@@ -126,29 +96,20 @@ this.pushToken(tok);

}
return true;
};
_proto.skipSymbol = function skipSymbol(val) {
return this.skipValue(lexer.TOKEN_SYMBOL, val);
};
_proto.advanceAfterBlockEnd = function advanceAfterBlockEnd(name) {
var tok;
if (!name) {
tok = this.peekToken();
if (!tok) {
this.fail('unexpected end of file');
}
if (tok.type !== lexer.TOKEN_SYMBOL) {
this.fail('advanceAfterBlockEnd: expected symbol token or ' + 'explicit name to be passed');
}
name = this.nextToken().value;
}
tok = this.nextToken();
if (tok && tok.type === lexer.TOKEN_BLOCK_END) {

@@ -161,9 +122,6 @@ if (tok.value.charAt(0) === '-') {

}
return tok;
};
_proto.advanceAfterVariableEnd = function advanceAfterVariableEnd() {
var tok = this.nextToken();
if (tok && tok.type === lexer.TOKEN_VARIABLE_END) {

@@ -176,3 +134,2 @@ this.dropLeadingWhitespace = tok.value.charAt(tok.value.length - this.tokens.tags.VARIABLE_END.length - 1) === '-';

};
_proto.parseFor = function parseFor() {

@@ -182,3 +139,2 @@ var forTok = this.peekToken();

var endBlock;
if (this.skipSymbol('for')) {

@@ -196,11 +152,7 @@ node = new nodes.For(forTok.lineno, forTok.colno);

}
node.name = this.parsePrimary();
if (!(node.name instanceof nodes.Symbol)) {
this.fail('parseFor: variable name expected for loop');
}
var type = this.peekToken().type;
if (type === lexer.TOKEN_COMMA) {

@@ -211,3 +163,2 @@ // key/value iteration

node.name.addChild(key);
while (this.skip(lexer.TOKEN_COMMA)) {

@@ -218,11 +169,8 @@ var prim = this.parsePrimary();

}
if (!this.skipSymbol('in')) {
this.fail('parseFor: expected "in" keyword for loop', forTok.lineno, forTok.colno);
}
node.arr = this.parseExpression();
this.advanceAfterBlockEnd(forTok.value);
node.body = this.parseUntilBlocks(endBlock, 'else');
if (this.skipSymbol('else')) {

@@ -232,14 +180,10 @@ this.advanceAfterBlockEnd('else');

}
this.advanceAfterBlockEnd();
return node;
};
_proto.parseMacro = function parseMacro() {
var macroTok = this.peekToken();
if (!this.skipSymbol('macro')) {
this.fail('expected macro');
}
var name = this.parsePrimary(true);

@@ -253,3 +197,2 @@ var args = this.parseSignature();

};
_proto.parseCall = function parseCall() {

@@ -259,7 +202,5 @@ // a call block is parsed as a normal FunCall, but with an added

var callTok = this.peekToken();
if (!this.skipSymbol('call')) {
this.fail('expected call');
}
var callerArgs = this.parseSignature(true) || new nodes.NodeList();

@@ -271,10 +212,9 @@ var macroCall = this.parsePrimary();

var callerName = new nodes.Symbol(callTok.lineno, callTok.colno, 'caller');
var callerNode = new nodes.Caller(callTok.lineno, callTok.colno, callerName, callerArgs, body); // add the additional caller kwarg, adding kwargs if necessary
var callerNode = new nodes.Caller(callTok.lineno, callTok.colno, callerName, callerArgs, body);
// add the additional caller kwarg, adding kwargs if necessary
var args = macroCall.args.children;
if (!(args[args.length - 1] instanceof nodes.KeywordArgs)) {
args.push(new nodes.KeywordArgs());
}
var kwargs = args[args.length - 1];

@@ -284,7 +224,5 @@ kwargs.addChild(new nodes.Pair(callTok.lineno, callTok.colno, callerName, callerNode));

};
_proto.parseWithContext = function parseWithContext() {
var tok = this.peekToken();
var withContext = null;
if (this.skipSymbol('with')) {

@@ -295,3 +233,2 @@ withContext = true;

}
if (withContext !== null) {

@@ -302,19 +239,13 @@ if (!this.skipSymbol('context')) {

}
return withContext;
};
_proto.parseImport = function parseImport() {
var importTok = this.peekToken();
if (!this.skipSymbol('import')) {
this.fail('parseImport: expected import', importTok.lineno, importTok.colno);
}
var template = this.parseExpression();
if (!this.skipSymbol('as')) {
this.fail('parseImport: expected "as" keyword', importTok.lineno, importTok.colno);
}
var target = this.parseExpression();

@@ -326,49 +257,37 @@ var withContext = this.parseWithContext();

};
_proto.parseFrom = function parseFrom() {
var fromTok = this.peekToken();
if (!this.skipSymbol('from')) {
this.fail('parseFrom: expected from');
}
var template = this.parseExpression();
if (!this.skipSymbol('import')) {
this.fail('parseFrom: expected import', fromTok.lineno, fromTok.colno);
}
var names = new nodes.NodeList();
var withContext;
while (1) {
// eslint-disable-line no-constant-condition
var nextTok = this.peekToken();
if (nextTok.type === lexer.TOKEN_BLOCK_END) {
if (!names.children.length) {
this.fail('parseFrom: Expected at least one import name', fromTok.lineno, fromTok.colno);
} // Since we are manually advancing past the block end,
}
// Since we are manually advancing past the block end,
// need to keep track of whitespace control (normally
// this is done in `advanceAfterBlockEnd`
if (nextTok.value.charAt(0) === '-') {
this.dropLeadingWhitespace = true;
}
this.nextToken();
break;
}
if (names.children.length > 0 && !this.skip(lexer.TOKEN_COMMA)) {
this.fail('parseFrom: expected comma', fromTok.lineno, fromTok.colno);
}
var name = this.parsePrimary();
if (name.value.charAt(0) === '_') {
this.fail('parseFrom: names starting with an underscore cannot be imported', name.lineno, name.colno);
}
if (this.skipSymbol('as')) {

@@ -380,23 +299,16 @@ var alias = this.parsePrimary();

}
withContext = this.parseWithContext();
}
return new nodes.FromImport(fromTok.lineno, fromTok.colno, template, names, withContext);
};
_proto.parseBlock = function parseBlock() {
var tag = this.peekToken();
if (!this.skipSymbol('block')) {
this.fail('parseBlock: expected block', tag.lineno, tag.colno);
}
var node = new nodes.Block(tag.lineno, tag.colno);
node.name = this.parsePrimary();
if (!(node.name instanceof nodes.Symbol)) {
this.fail('parseBlock: variable name expected', tag.lineno, tag.colno);
}
this.advanceAfterBlockEnd(tag.value);

@@ -407,19 +319,14 @@ node.body = this.parseUntilBlocks('endblock');

var tok = this.peekToken();
if (!tok) {
this.fail('parseBlock: expected endblock, got end of file');
}
this.advanceAfterBlockEnd(tok.value);
return node;
};
_proto.parseExtends = function parseExtends() {
var tagName = 'extends';
var tag = this.peekToken();
if (!this.skipSymbol(tagName)) {
this.fail('parseTemplateRef: expected ' + tagName);
}
var node = new nodes.Extends(tag.lineno, tag.colno);

@@ -430,26 +337,19 @@ node.template = this.parseExpression();

};
_proto.parseInclude = function parseInclude() {
var tagName = 'include';
var tag = this.peekToken();
if (!this.skipSymbol(tagName)) {
this.fail('parseInclude: expected ' + tagName);
}
var node = new nodes.Include(tag.lineno, tag.colno);
node.template = this.parseExpression();
if (this.skipSymbol('ignore') && this.skipSymbol('missing')) {
node.ignoreMissing = true;
}
this.advanceAfterBlockEnd(tag.value);
return node;
};
_proto.parseIf = function parseIf() {
var tag = this.peekToken();
var node;
if (this.skipSymbol('if') || this.skipSymbol('elif') || this.skipSymbol('elseif')) {

@@ -462,3 +362,2 @@ node = new nodes.If(tag.lineno, tag.colno);

}
node.cond = this.parseExpression();

@@ -468,3 +367,2 @@ this.advanceAfterBlockEnd(tag.value);

var tok = this.peekToken();
switch (tok && tok.value) {

@@ -475,3 +373,2 @@ case 'elseif':

break;
case 'else':

@@ -482,3 +379,2 @@ this.advanceAfterBlockEnd();

break;
case 'endif':

@@ -488,23 +384,16 @@ node.else_ = null;

break;
default:
this.fail('parseIf: expected elif, else, or endif, got end of file');
}
return node;
};
_proto.parseSet = function parseSet() {
var tag = this.peekToken();
if (!this.skipSymbol('set')) {
this.fail('parseSet: expected set', tag.lineno, tag.colno);
}
var node = new nodes.Set(tag.lineno, tag.colno, []);
var target;
while (target = this.parsePrimary()) {
node.targets.push(target);
if (!this.skip(lexer.TOKEN_COMMA)) {

@@ -514,3 +403,2 @@ break;

}
if (!this.skipValue(lexer.TOKEN_OPERATOR, '=')) {

@@ -528,6 +416,4 @@ if (!this.skip(lexer.TOKEN_BLOCK_END)) {

}
return node;
};
_proto.parseSwitch = function parseSwitch() {

@@ -541,21 +427,27 @@ /*

var caseStart = 'case';
var caseDefault = 'default'; // Get the switch tag.
var caseDefault = 'default';
var tag = this.peekToken(); // fail early if we get some unexpected tag.
// Get the switch tag.
var tag = this.peekToken();
// fail early if we get some unexpected tag.
if (!this.skipSymbol(switchStart) && !this.skipSymbol(caseStart) && !this.skipSymbol(caseDefault)) {
this.fail('parseSwitch: expected "switch," "case" or "default"', tag.lineno, tag.colno);
} // parse the switch expression
}
// parse the switch expression
var expr = this.parseExpression();
var expr = this.parseExpression(); // advance until a start of a case, a default case or an endswitch.
// advance until a start of a case, a default case or an endswitch.
this.advanceAfterBlockEnd(switchStart);
this.parseUntilBlocks(caseStart, caseDefault, switchEnd); // this is the first case. it could also be an endswitch, we'll check.
this.parseUntilBlocks(caseStart, caseDefault, switchEnd);
var tok = this.peekToken(); // create new variables for our cases and default case.
// this is the first case. it could also be an endswitch, we'll check.
var tok = this.peekToken();
// create new variables for our cases and default case.
var cases = [];
var defaultCase; // while we're dealing with new cases nodes...
var defaultCase;
// while we're dealing with new cases nodes...
do {

@@ -565,11 +457,11 @@ // skip the start symbol and get the case expression

var cond = this.parseExpression();
this.advanceAfterBlockEnd(switchStart); // get the body of the case node and add it to the array of cases.
this.advanceAfterBlockEnd(switchStart);
// get the body of the case node and add it to the array of cases.
var body = this.parseUntilBlocks(caseStart, caseDefault, switchEnd);
cases.push(new nodes.Case(tok.line, tok.col, cond, body)); // get our next case
cases.push(new nodes.Case(tok.line, tok.col, cond, body));
// get our next case
tok = this.peekToken();
} while (tok && tok.value === caseStart); // we either have a default case or a switch end.
} while (tok && tok.value === caseStart);
// we either have a default case or a switch end.
switch (tok.value) {

@@ -581,39 +473,30 @@ case caseDefault:

break;
case switchEnd:
this.advanceAfterBlockEnd();
break;
default:
// otherwise bail because EOF
this.fail('parseSwitch: expected "case," "default" or "endswitch," got EOF.');
} // and return the switch node.
}
// and return the switch node.
return new nodes.Switch(tag.lineno, tag.colno, expr, cases, defaultCase);
};
_proto.parseStatement = function parseStatement() {
var tok = this.peekToken();
var node;
if (tok.type !== lexer.TOKEN_SYMBOL) {
this.fail('tag name expected', tok.lineno, tok.colno);
}
if (this.breakOnBlocks && lib.indexOf(this.breakOnBlocks, tok.value) !== -1) {
return null;
}
switch (tok.value) {
case 'raw':
return this.parseRaw();
case 'verbatim':
return this.parseRaw('verbatim');
case 'if':
case 'ifAsync':
return this.parseIf();
case 'for':

@@ -623,33 +506,22 @@ case 'asyncEach':

return this.parseFor();
case 'block':
return this.parseBlock();
case 'extends':
return this.parseExtends();
case 'include':
return this.parseInclude();
case 'set':
return this.parseSet();
case 'macro':
return this.parseMacro();
case 'call':
return this.parseCall();
case 'import':
return this.parseImport();
case 'from':
return this.parseFrom();
case 'filter':
return this.parseFilterStatement();
case 'switch':
return this.parseSwitch();
default:

@@ -659,3 +531,2 @@ if (this.extensions.length) {

var ext = this.extensions[i];
if (lib.indexOf(ext.tags || [], tok.value) !== -1) {

@@ -666,27 +537,27 @@ return ext.parse(this, nodes, lexer);

}
this.fail('unknown block tag: ' + tok.value, tok.lineno, tok.colno);
}
return node;
};
_proto.parseRaw = function parseRaw(tagName) {
tagName = tagName || 'raw';
var endTagName = 'end' + tagName; // Look for upcoming raw blocks (ignore all other kinds of blocks)
var endTagName = 'end' + tagName;
// Look for upcoming raw blocks (ignore all other kinds of blocks)
var rawBlockRegex = new RegExp('([\\s\\S]*?){%\\s*(' + tagName + '|' + endTagName + ')\\s*(?=%})%}');
var rawLevel = 1;
var str = '';
var matches = null; // Skip opening raw token
var matches = null;
// Skip opening raw token
// Keep this token to track line and column numbers
var begun = this.advanceAfterBlockEnd();
var begun = this.advanceAfterBlockEnd(); // Exit when there's nothing to match
// Exit when there's nothing to match
// or when we've found the matching "endraw" block
while ((matches = this.tokens._extractRegex(rawBlockRegex)) && rawLevel > 0) {
var all = matches[0];
var pre = matches[1];
var blockName = matches[2]; // Adjust rawlevel
var blockName = matches[2];
// Adjust rawlevel
if (blockName === tagName) {

@@ -696,9 +567,9 @@ rawLevel += 1;

rawLevel -= 1;
} // Add to str
}
// Add to str
if (rawLevel === 0) {
// We want to exclude the last "endraw"
str += pre; // Move tokenizer to beginning of endraw block
str += pre;
// Move tokenizer to beginning of endraw block
this.tokens.backN(all.length - pre.length);

@@ -709,10 +580,7 @@ } else {

}
return new nodes.Output(begun.lineno, begun.colno, [new nodes.TemplateData(begun.lineno, begun.colno, str)]);
};
_proto.parsePostfix = function parsePostfix(node) {
var lookup;
var tok = this.peekToken();
while (tok) {

@@ -725,7 +593,5 @@ if (tok.type === lexer.TOKEN_LEFT_PAREN) {

lookup = this.parseAggregate();
if (lookup.children.length > 1) {
this.fail('invalid index');
}
node = new nodes.LookupVal(tok.lineno, tok.colno, node, lookup.children[0]);

@@ -736,9 +602,8 @@ } else if (tok.type === lexer.TOKEN_OPERATOR && tok.value === '.') {

var val = this.nextToken();
if (val.type !== lexer.TOKEN_SYMBOL) {
this.fail('expected name as lookup value, got ' + val.value, val.lineno, val.colno);
} // Make a literal string because it's not a variable
}
// Make a literal string because it's not a variable
// reference
lookup = new nodes.Literal(val.lineno, val.colno, val.value);

@@ -749,9 +614,6 @@ node = new nodes.LookupVal(tok.lineno, tok.colno, node, lookup);

}
tok = this.peekToken();
}
return node;
};
_proto.parseExpression = function parseExpression() {

@@ -761,6 +623,4 @@ var node = this.parseInlineIf();

};
_proto.parseInlineIf = function parseInlineIf() {
var node = this.parseOr();
if (this.skipSymbol('if')) {

@@ -772,3 +632,2 @@ var condNode = this.parseOr();

node.cond = condNode;
if (this.skipSymbol('else')) {

@@ -780,9 +639,6 @@ node.else_ = this.parseOr();

}
return node;
};
_proto.parseOr = function parseOr() {
var node = this.parseAnd();
while (this.skipSymbol('or')) {

@@ -792,9 +648,6 @@ var node2 = this.parseAnd();

}
return node;
};
_proto.parseAnd = function parseAnd() {
var node = this.parseNot();
while (this.skipSymbol('and')) {

@@ -804,19 +657,13 @@ var node2 = this.parseNot();

}
return node;
};
_proto.parseNot = function parseNot() {
var tok = this.peekToken();
if (this.skipSymbol('not')) {
return new nodes.Not(tok.lineno, tok.colno, this.parseNot());
}
return this.parseIn();
};
_proto.parseIn = function parseIn() {
var node = this.parseIs();
while (1) {

@@ -826,17 +673,13 @@ // eslint-disable-line no-constant-condition

var tok = this.nextToken();
if (!tok) {
break;
}
var invert = tok.type === lexer.TOKEN_SYMBOL && tok.value === 'not'; // if it wasn't 'not', put it back
var invert = tok.type === lexer.TOKEN_SYMBOL && tok.value === 'not';
// if it wasn't 'not', put it back
if (!invert) {
this.pushToken(tok);
}
if (this.skipSymbol('in')) {
var node2 = this.parseIs();
node = new nodes.In(node.lineno, node.colno, node, node2);
if (invert) {

@@ -850,32 +693,29 @@ node = new nodes.Not(node.lineno, node.colno, node);

}
break;
}
}
return node;
}
return node;
} // I put this right after "in" in the operator precedence stack. That can
// I put this right after "in" in the operator precedence stack. That can
// obviously be changed to be closer to Jinja.
;
_proto.parseIs = function parseIs() {
var node = this.parseCompare(); // look for an is
var node = this.parseCompare();
// look for an is
if (this.skipSymbol('is')) {
// look for a not
var not = this.skipSymbol('not'); // get the next node
var node2 = this.parseCompare(); // create an Is node using the next node and the info from our Is node.
node = new nodes.Is(node.lineno, node.colno, node, node2); // if we have a Not, create a Not node from our Is node.
var not = this.skipSymbol('not');
// get the next node
var node2 = this.parseCompare();
// create an Is node using the next node and the info from our Is node.
node = new nodes.Is(node.lineno, node.colno, node, node2);
// if we have a Not, create a Not node from our Is node.
if (not) {
node = new nodes.Not(node.lineno, node.colno, node);
}
} // return the node.
}
// return the node.
return node;
};
_proto.parseCompare = function parseCompare() {

@@ -885,7 +725,5 @@ var compareOps = ['==', '===', '!=', '!==', '<', '>', '<=', '>='];

var ops = [];
while (1) {
// eslint-disable-line no-constant-condition
var tok = this.nextToken();
if (!tok) {

@@ -900,3 +738,2 @@ break;

}
if (ops.length) {

@@ -907,8 +744,8 @@ return new nodes.Compare(ops[0].lineno, ops[0].colno, expr, ops);

}
} // finds the '~' for string concatenation
}
// finds the '~' for string concatenation
;
_proto.parseConcat = function parseConcat() {
var node = this.parseAdd();
while (this.skipValue(lexer.TOKEN_TILDE, '~')) {

@@ -918,9 +755,6 @@ var node2 = this.parseAdd();

}
return node;
};
_proto.parseAdd = function parseAdd() {
var node = this.parseSub();
while (this.skipValue(lexer.TOKEN_OPERATOR, '+')) {

@@ -930,9 +764,6 @@ var node2 = this.parseSub();

}
return node;
};
_proto.parseSub = function parseSub() {
var node = this.parseMul();
while (this.skipValue(lexer.TOKEN_OPERATOR, '-')) {

@@ -942,9 +773,6 @@ var node2 = this.parseMul();

}
return node;
};
_proto.parseMul = function parseMul() {
var node = this.parseDiv();
while (this.skipValue(lexer.TOKEN_OPERATOR, '*')) {

@@ -954,9 +782,6 @@ var node2 = this.parseDiv();

}
return node;
};
_proto.parseDiv = function parseDiv() {
var node = this.parseFloorDiv();
while (this.skipValue(lexer.TOKEN_OPERATOR, '/')) {

@@ -966,9 +791,6 @@ var node2 = this.parseFloorDiv();

}
return node;
};
_proto.parseFloorDiv = function parseFloorDiv() {
var node = this.parseMod();
while (this.skipValue(lexer.TOKEN_OPERATOR, '//')) {

@@ -978,9 +800,6 @@ var node2 = this.parseMod();

}
return node;
};
_proto.parseMod = function parseMod() {
var node = this.parsePow();
while (this.skipValue(lexer.TOKEN_OPERATOR, '%')) {

@@ -990,9 +809,6 @@ var node2 = this.parsePow();

}
return node;
};
_proto.parsePow = function parsePow() {
var node = this.parseUnary();
while (this.skipValue(lexer.TOKEN_OPERATOR, '**')) {

@@ -1002,10 +818,7 @@ var node2 = this.parseUnary();

}
return node;
};
_proto.parseUnary = function parseUnary(noFilters) {
var tok = this.peekToken();
var node;
if (this.skipValue(lexer.TOKEN_OPERATOR, '-')) {

@@ -1018,10 +831,7 @@ node = new nodes.Neg(tok.lineno, tok.colno, this.parseUnary(true));

}
if (!noFilters) {
node = this.parseFilter(node);
}
return node;
};
_proto.parsePrimary = function parsePrimary(noPostfix) {

@@ -1031,3 +841,2 @@ var tok = this.nextToken();

var node = null;
if (!tok) {

@@ -1054,3 +863,2 @@ this.fail('expected expression, got end of file');

}
if (val !== undefined) {

@@ -1066,7 +874,5 @@ node = new nodes.Literal(tok.lineno, tok.colno, val);

}
if (!noPostfix) {
node = this.parsePostfix(node);
}
if (node) {

@@ -1078,14 +884,10 @@ return node;

};
_proto.parseFilterName = function parseFilterName() {
var tok = this.expect(lexer.TOKEN_SYMBOL);
var name = tok.value;
while (this.skipValue(lexer.TOKEN_OPERATOR, '.')) {
name += '.' + this.expect(lexer.TOKEN_SYMBOL).value;
}
return new nodes.Symbol(tok.lineno, tok.colno, name);
};
_proto.parseFilterArgs = function parseFilterArgs(node) {

@@ -1098,6 +900,4 @@ if (this.peekToken().type === lexer.TOKEN_LEFT_PAREN) {

}
return [];
};
_proto.parseFilter = function parseFilter(node) {

@@ -1108,13 +908,9 @@ while (this.skip(lexer.TOKEN_PIPE)) {

}
return node;
};
_proto.parseFilterStatement = function parseFilterStatement() {
var filterTok = this.peekToken();
if (!this.skipSymbol('filter')) {
this.fail('parseFilterStatement: expected filter');
}
var name = this.parseFilterName();

@@ -1128,7 +924,5 @@ var args = this.parseFilterArgs(name);

};
_proto.parseAggregate = function parseAggregate() {
var tok = this.nextToken();
var node;
switch (tok.type) {

@@ -1138,19 +932,14 @@ case lexer.TOKEN_LEFT_PAREN:

break;
case lexer.TOKEN_LEFT_BRACKET:
node = new nodes.Array(tok.lineno, tok.colno);
break;
case lexer.TOKEN_LEFT_CURLY:
node = new nodes.Dict(tok.lineno, tok.colno);
break;
default:
return null;
}
while (1) {
// eslint-disable-line no-constant-condition
var type = this.peekToken().type;
if (type === lexer.TOKEN_RIGHT_PAREN || type === lexer.TOKEN_RIGHT_BRACKET || type === lexer.TOKEN_RIGHT_CURLY) {

@@ -1160,3 +949,2 @@ this.nextToken();

}
if (node.children.length > 0) {

@@ -1167,13 +955,13 @@ if (!this.skip(lexer.TOKEN_COMMA)) {

}
if (node instanceof nodes.Dict) {
// TODO: check for errors
var key = this.parsePrimary(); // We expect a key/value pair for dicts, separated by a
var key = this.parsePrimary();
// We expect a key/value pair for dicts, separated by a
// colon
if (!this.skip(lexer.TOKEN_COLON)) {
this.fail('parseAggregate: expected colon after dict key', tok.lineno, tok.colno);
} // TODO: check for errors
}
// TODO: check for errors
var value = this.parseExpression();

@@ -1187,9 +975,6 @@ node.addChild(new nodes.Pair(key.lineno, key.colno, key, value));

}
return node;
};
_proto.parseSignature = function parseSignature(tolerant, noParens) {
var tok = this.peekToken();
if (!noParens && tok.type !== lexer.TOKEN_LEFT_PAREN) {

@@ -1202,15 +987,11 @@ if (tolerant) {

}
if (tok.type === lexer.TOKEN_LEFT_PAREN) {
tok = this.nextToken();
}
var args = new nodes.NodeList(tok.lineno, tok.colno);
var kwargs = new nodes.KeywordArgs(tok.lineno, tok.colno);
var checkComma = false;
while (1) {
// eslint-disable-line no-constant-condition
tok = this.peekToken();
if (!noParens && tok.type === lexer.TOKEN_RIGHT_PAREN) {

@@ -1222,3 +1003,2 @@ this.nextToken();

}
if (checkComma && !this.skip(lexer.TOKEN_COMMA)) {

@@ -1228,3 +1008,2 @@ this.fail('parseSignature: expected comma after expression', tok.lineno, tok.colno);

var arg = this.parseExpression();
if (this.skipValue(lexer.TOKEN_OPERATOR, '=')) {

@@ -1236,20 +1015,14 @@ kwargs.addChild(new nodes.Pair(arg.lineno, arg.colno, arg, this.parseExpression()));

}
checkComma = true;
}
if (kwargs.children.length) {
args.addChild(kwargs);
}
return args;
};
_proto.parseUntilBlocks = function parseUntilBlocks() {
var prev = this.breakOnBlocks;
for (var _len = arguments.length, blockNames = new Array(_len), _key = 0; _key < _len; _key++) {
blockNames[_key] = arguments[_key];
}
this.breakOnBlocks = blockNames;

@@ -1260,7 +1033,5 @@ var ret = this.parse();

};
_proto.parseNodes = function parseNodes() {
var tok;
var buf = [];
while (tok = this.nextToken()) {

@@ -1270,6 +1041,7 @@ if (tok.type === lexer.TOKEN_DATA) {

var nextToken = this.peekToken();
var nextVal = nextToken && nextToken.value; // If the last token has "-" we need to trim the
var nextVal = nextToken && nextToken.value;
// If the last token has "-" we need to trim the
// leading whitespace of the data. This is marked with
// the `dropLeadingWhitespace` variable.
if (this.dropLeadingWhitespace) {

@@ -1279,5 +1051,5 @@ // TODO: this could be optimized (don't use regex)

this.dropLeadingWhitespace = false;
} // Same for the succeeding block start token
}
// Same for the succeeding block start token
if (nextToken && (nextToken.type === lexer.TOKEN_BLOCK_START && nextVal.charAt(nextVal.length - 1) === '-' || nextToken.type === lexer.TOKEN_VARIABLE_START && nextVal.charAt(this.tokens.tags.VARIABLE_START.length) === '-' || nextToken.type === lexer.TOKEN_COMMENT && nextVal.charAt(this.tokens.tags.COMMENT_START.length) === '-')) {

@@ -1287,3 +1059,2 @@ // TODO: this could be optimized (don't use regex)

}
buf.push(new nodes.Output(tok.lineno, tok.colno, [new nodes.TemplateData(tok.lineno, tok.colno, data)]));

@@ -1293,7 +1064,5 @@ } else if (tok.type === lexer.TOKEN_BLOCK_START) {

var n = this.parseStatement();
if (!n) {
break;
}
buf.push(n);

@@ -1312,14 +1081,10 @@ } else if (tok.type === lexer.TOKEN_VARIABLE_START) {

}
return buf;
};
_proto.parse = function parse() {
return new nodes.NodeList(0, 0, this.parseNodes());
};
_proto.parseAsRoot = function parseAsRoot() {
return new nodes.Root(0, 0, this.parseNodes());
};
return Parser;

@@ -1337,12 +1102,8 @@ }(Obj); // var util = require('util');

// nodes.printNodes(n);
module.exports = {
parse: function parse(src, extensions, opts) {
var p = new Parser(lexer.lex(src, opts));
if (extensions !== undefined) {
p.extensions = extensions;
}
return p.parseAsRoot();

@@ -1349,0 +1110,0 @@ },

@@ -6,3 +6,2 @@ 'use strict';

opts = opts || {};
for (var i = 0; i < templates.length; i++) {

@@ -12,13 +11,9 @@ var name = JSON.stringify(templates[i].name);

out += '(function() {' + '(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})' + '[' + name + '] = (function() {\n' + template + '\n})();\n';
if (opts.asFunction) {
out += 'return function(ctx, cb) { return nunjucks.render(' + name + ', ctx, cb); }\n';
}
out += '})();\n';
}
return out;
}
module.exports = precompileGlobal;
'use strict';
var fs = require('fs');
var path = require('path');
var _require = require('./lib'),
_prettifyError = _require._prettifyError;
_prettifyError = _require._prettifyError;
var compiler = require('./compiler');
var _require2 = require('./environment'),
Environment = _require2.Environment;
Environment = _require2.Environment;
var precompileGlobal = require('./precompile-global');
function match(filename, patterns) {

@@ -21,3 +15,2 @@ if (!Array.isArray(patterns)) {

}
return patterns.some(function (pattern) {

@@ -27,3 +20,2 @@ return filename.match(pattern);

}
function precompileString(str, opts) {

@@ -34,10 +26,7 @@ opts = opts || {};

var wrapper = opts.wrapper || precompileGlobal;
if (!opts.name) {
throw new Error('the "name" option is required when compiling a string');
}
return wrapper([_precompile(str, opts.name, env)], opts);
}
function precompile(input, opts) {

@@ -57,14 +46,12 @@ // The following options are available:

// A custom loader will be necessary to load your custom wrapper.
opts = opts || {};
var env = opts.env || new Environment([]);
var wrapper = opts.wrapper || precompileGlobal;
if (opts.isString) {
return precompileString(input, opts);
}
var pathStats = fs.existsSync(input) && fs.statSync(input);
var precompiled = [];
var templates = [];
function addTemplates(dir) {

@@ -75,6 +62,4 @@ fs.readdirSync(dir).forEach(function (file) {

var stat = fs.statSync(filepath);
if (stat && stat.isDirectory()) {
subpath += '/';
if (!match(subpath, opts.exclude)) {

@@ -88,3 +73,2 @@ addTemplates(filepath);

}
if (pathStats.isFile()) {

@@ -94,6 +78,4 @@ precompiled.push(_precompile(fs.readFileSync(input, 'utf-8'), opts.name || input, env));

addTemplates(input);
for (var i = 0; i < templates.length; i++) {
var name = templates[i].replace(path.join(input, '/'), '');
try {

@@ -112,6 +94,4 @@ precompiled.push(_precompile(fs.readFileSync(templates[i], 'utf-8'), name, env));

}
return wrapper(precompiled, opts);
}
function _precompile(str, name, env) {

@@ -123,3 +103,2 @@ env = env || new Environment([]);

name = name.replace(/\\/g, '/');
try {

@@ -130,3 +109,2 @@ template = compiler.compile(str, asyncFilters, extensions, name, env.opts);

}
return {

@@ -137,3 +115,2 @@ name: name,

}
module.exports = {

@@ -140,0 +117,0 @@ precompile: precompile,

'use strict';
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var Loader = require('./loader');
var PrecompiledLoader = /*#__PURE__*/function (_Loader) {
_inheritsLoose(PrecompiledLoader, _Loader);
function PrecompiledLoader(compiledTemplates) {
var _this;
_this = _Loader.call(this) || this;

@@ -19,5 +14,3 @@ _this.precompiled = compiledTemplates || {};

}
var _proto = PrecompiledLoader.prototype;
_proto.getSource = function getSource(name) {

@@ -33,11 +26,8 @@ if (this.precompiled[name]) {

}
return null;
};
return PrecompiledLoader;
}(Loader);
module.exports = {
PrecompiledLoader: PrecompiledLoader
};
'use strict';
var lib = require('./lib');
var arrayFrom = Array.from;
var supportsIterators = typeof Symbol === 'function' && Symbol.iterator && typeof arrayFrom === 'function';
var arrayFrom = Array.from;
var supportsIterators = typeof Symbol === 'function' && Symbol.iterator && typeof arrayFrom === 'function'; // Frames keep track of scoping both at compile-time and run-time so
// Frames keep track of scoping both at compile-time and run-time so
// we know how to access variables. Block tags can introduce special
// variables, for example.
var Frame = /*#__PURE__*/function () {

@@ -14,10 +14,8 @@ function Frame(parent, isolateWrites) {

this.parent = parent;
this.topLevel = false; // if this is true, writes (set) should never propagate upwards past
this.topLevel = false;
// if this is true, writes (set) should never propagate upwards past
// this frame to its parent (though reads may).
this.isolateWrites = isolateWrites;
}
var _proto = Frame.prototype;
_proto.set = function set(name, val, resolveUp) {

@@ -29,3 +27,2 @@ // Allow variables with dots by automatically creating the

var frame = this;
if (resolveUp) {

@@ -37,59 +34,42 @@ if (frame = this.resolve(parts[0], true)) {

}
for (var i = 0; i < parts.length - 1; i++) {
var id = parts[i];
if (!obj[id]) {
obj[id] = {};
}
obj = obj[id];
}
obj[parts[parts.length - 1]] = val;
};
_proto.get = function get(name) {
var val = this.variables[name];
if (val !== undefined) {
return val;
}
return null;
};
_proto.lookup = function lookup(name) {
var p = this.parent;
var val = this.variables[name];
if (val !== undefined) {
return val;
}
return p && p.lookup(name);
};
_proto.resolve = function resolve(name, forWrite) {
var p = forWrite && this.isolateWrites ? undefined : this.parent;
var val = this.variables[name];
if (val !== undefined) {
return this;
}
return p && p.resolve(name);
};
_proto.push = function push(isolateWrites) {
return new Frame(this, isolateWrites);
};
_proto.pop = function pop() {
return this.parent;
};
return Frame;
}();
function makeMacro(argNames, kwargNames, func) {

@@ -100,11 +80,10 @@ return function macro() {

}
var argCount = numArgs(macroArgs);
var args;
var kwargs = getKeywordArgs(macroArgs);
if (argCount > argNames.length) {
args = macroArgs.slice(0, argNames.length);
if (argCount > argNames.length) {
args = macroArgs.slice(0, argNames.length); // Positional arguments that should be passed in as
// Positional arguments that should be passed in as
// keyword arguments (essentially default values)
macroArgs.slice(args.length, argCount).forEach(function (val, i) {

@@ -118,12 +97,11 @@ if (i < kwargNames.length) {

args = macroArgs.slice(0, argCount);
for (var i = argCount; i < argNames.length; i++) {
var arg = argNames[i];
for (var i = argCount; i < argNames.length; i++) {
var arg = argNames[i]; // Keyword arguments that should be passed as
// Keyword arguments that should be passed as
// positional arguments, i.e. the caller explicitly
// used the name of a positional arg
args.push(kwargs[arg]);
delete kwargs[arg];
}
args.push(kwargs);

@@ -133,7 +111,5 @@ } else {

}
return func.apply(this, args);
};
}
function makeKeywordArgs(obj) {

@@ -143,13 +119,9 @@ obj.__keywords = true;

}
function isKeywordArgs(obj) {
return obj && Object.prototype.hasOwnProperty.call(obj, '__keywords');
}
function getKeywordArgs(args) {
var len = args.length;
if (len) {
var lastArg = args[len - 1];
if (isKeywordArgs(lastArg)) {

@@ -159,15 +131,10 @@ return lastArg;

}
return {};
}
function numArgs(args) {
var len = args.length;
if (len === 0) {
return 0;
}
var lastArg = args[len - 1];
if (isKeywordArgs(lastArg)) {

@@ -178,7 +145,7 @@ return len - 1;

}
} // A SafeString object indicates that the string should not be
}
// A SafeString object indicates that the string should not be
// autoescaped. This happens magically because autoescaping only
// occurs on primitive string objects.
function SafeString(val) {

@@ -188,7 +155,5 @@ if (typeof val !== 'string') {

}
this.val = val;
this.length = val.length;
}
SafeString.prototype = Object.create(String.prototype, {

@@ -201,11 +166,8 @@ length: {

});
SafeString.prototype.valueOf = function valueOf() {
return this.val;
};
SafeString.prototype.toString = function toString() {
return this.val;
};
function copySafeness(dest, target) {

@@ -215,9 +177,6 @@ if (dest instanceof SafeString) {

}
return target.toString();
}
function markSafe(val) {
var type = typeof val;
if (type === 'string') {

@@ -230,7 +189,5 @@ return new SafeString(val);

var ret = val.apply(this, arguments);
if (typeof ret === 'string') {
return new SafeString(ret);
}
return ret;

@@ -240,13 +197,9 @@ };

}
function suppressValue(val, autoescape) {
val = val !== undefined && val !== null ? val : '';
if (autoescape && !(val instanceof SafeString)) {
val = lib.escape(val.toString());
}
return val;
}
function ensureDefined(val, lineno, colno) {

@@ -256,6 +209,4 @@ if (val === null || val === undefined) {

}
return val;
}
function memberLookup(obj, val) {

@@ -265,3 +216,2 @@ if (obj === undefined || obj === null) {

}
if (typeof obj[val] === 'function') {

@@ -272,10 +222,7 @@ return function () {

}
return obj[val].apply(obj, args);
};
}
return obj[val];
}
function callWrap(obj, name, context, args) {

@@ -287,6 +234,4 @@ if (!obj) {

}
return obj.apply(context, args);
}
function contextOrFrameLookup(context, frame, name) {

@@ -296,3 +241,2 @@ var val = frame.lookup(name);

}
function handleError(error, lineno, colno) {

@@ -305,3 +249,2 @@ if (error.lineno) {

}
function asyncEach(arr, dimen, iter, cb) {

@@ -315,11 +258,8 @@ if (lib.isArray(arr)) {

break;
case 2:
iter(item[0], item[1], i, len, next);
break;
case 3:
iter(item[0], item[1], item[2], i, len, next);
break;
default:

@@ -336,3 +276,2 @@ item.push(i, len, next);

}
function asyncAll(arr, dimen, func, cb) {

@@ -342,7 +281,5 @@ var finished = 0;

var outputArr;
function done(i, output) {
finished++;
outputArr[i] = output;
if (finished === len) {

@@ -352,7 +289,5 @@ cb(null, outputArr.join(''));

}
if (lib.isArray(arr)) {
len = arr.length;
outputArr = new Array(len);
if (len === 0) {

@@ -363,3 +298,2 @@ cb(null, '');

var item = arr[i];
switch (dimen) {

@@ -369,11 +303,8 @@ case 1:

break;
case 2:
func(item[0], item[1], i, len, done);
break;
case 3:
func(item[0], item[1], item[2], i, len, done);
break;
default:

@@ -389,3 +320,2 @@ item.push(i, len, done);

outputArr = new Array(len);
if (len === 0) {

@@ -401,3 +331,2 @@ cb(null, '');

}
function fromIterator(arr) {

@@ -412,3 +341,2 @@ if (typeof arr !== 'object' || arr === null || lib.isArray(arr)) {

}
module.exports = {

@@ -415,0 +343,0 @@ Frame: Frame,

'use strict';
var SafeString = require('./runtime').SafeString;
/**

@@ -9,9 +10,7 @@ * Returns `true` if the object is a function, otherwise `false`.

*/
function callable(value) {
return typeof value === 'function';
}
exports.callable = callable;
exports.callable = callable;
/**

@@ -22,8 +21,7 @@ * Returns `true` if the object is strictly not `undefined`.

*/
function defined(value) {
return value !== undefined;
}
exports.defined = defined;
exports.defined = defined;
/**

@@ -36,8 +34,7 @@ * Returns `true` if the operand (one) is divisble by the test's argument

*/
function divisibleby(one, two) {
return one % two === 0;
}
exports.divisibleby = divisibleby;
exports.divisibleby = divisibleby;
/**

@@ -48,8 +45,7 @@ * Returns true if the string has been escaped (i.e., is a SafeString).

*/
function escaped(value) {
return value instanceof SafeString;
}
exports.escaped = escaped;
exports.escaped = escaped;
/**

@@ -60,11 +56,11 @@ * Returns `true` if the arguments are strictly equal.

*/
function equalto(one, two) {
return one === two;
}
exports.equalto = equalto;
exports.equalto = equalto; // Aliases
// Aliases
exports.eq = exports.equalto;
exports.sameas = exports.equalto;
/**

@@ -75,8 +71,7 @@ * Returns `true` if the value is evenly divisible by 2.

*/
function even(value) {
return value % 2 === 0;
}
exports.even = even;
exports.even = even;
/**

@@ -90,8 +85,7 @@ * Returns `true` if the value is falsy - if I recall correctly, '', 0, false,

*/
function falsy(value) {
return !value;
}
exports.falsy = falsy;
exports.falsy = falsy;
/**

@@ -104,8 +98,7 @@ * Returns `true` if the operand (one) is greater or equal to the test's

*/
function ge(one, two) {
return one >= two;
}
exports.ge = ge;
exports.ge = ge;
/**

@@ -118,10 +111,10 @@ * Returns `true` if the operand (one) is greater than the test's argument

*/
function greaterthan(one, two) {
return one > two;
}
exports.greaterthan = greaterthan;
exports.greaterthan = greaterthan; // alias
// alias
exports.gt = exports.greaterthan;
exports.gt = exports.greaterthan;
/**

@@ -134,8 +127,7 @@ * Returns `true` if the operand (one) is less than or equal to the test's

*/
function le(one, two) {
return one <= two;
}
exports.le = le;
exports.le = le;
/**

@@ -148,10 +140,10 @@ * Returns `true` if the operand (one) is less than the test's passed argument

*/
function lessthan(one, two) {
return one < two;
}
exports.lessthan = lessthan;
exports.lessthan = lessthan; // alias
// alias
exports.lt = exports.lessthan;
exports.lt = exports.lessthan;
/**

@@ -162,8 +154,7 @@ * Returns `true` if the string is lowercased.

*/
function lower(value) {
return value.toLowerCase() === value;
}
exports.lower = lower;
exports.lower = lower;
/**

@@ -176,8 +167,7 @@ * Returns `true` if the operand (one) is less than or equal to the test's

*/
function ne(one, two) {
return one !== two;
}
exports.ne = ne;
exports.ne = ne;
/**

@@ -188,8 +178,7 @@ * Returns true if the value is strictly equal to `null`.

*/
function nullTest(value) {
return value === null;
}
exports.null = nullTest;
exports.null = nullTest;
/**

@@ -200,8 +189,7 @@ * Returns true if value is a number.

*/
function number(value) {
return typeof value === 'number';
}
exports.number = number;
exports.number = number;
/**

@@ -212,8 +200,7 @@ * Returns `true` if the value is *not* evenly divisible by 2.

*/
function odd(value) {
return value % 2 === 1;
}
exports.odd = odd;
exports.odd = odd;
/**

@@ -224,8 +211,7 @@ * Returns `true` if the value is a string, `false` if not.

*/
function string(value) {
return typeof value === 'string';
}
exports.string = string;
exports.string = string;
/**

@@ -237,8 +223,7 @@ * Returns `true` if the value is not in the list of things considered falsy:

*/
function truthy(value) {
return !!value;
}
exports.truthy = truthy;
exports.truthy = truthy;
/**

@@ -249,8 +234,7 @@ * Returns `true` if the value is undefined.

*/
function undefinedTest(value) {
return value === undefined;
}
exports.undefined = undefinedTest;
exports.undefined = undefinedTest;
/**

@@ -261,8 +245,7 @@ * Returns `true` if the string is uppercased.

*/
function upper(value) {
return value.toUpperCase() === value;
}
exports.upper = upper;
exports.upper = upper;
/**

@@ -278,3 +261,2 @@ * If ES6 features are available, returns `true` if the value implements the

*/
function iterable(value) {

@@ -287,4 +269,4 @@ if (typeof Symbol !== 'undefined') {

}
exports.iterable = iterable;
exports.iterable = iterable;
/**

@@ -296,7 +278,5 @@ * If ES6 features are available, returns `true` if the value is an object hash

*/
function mapping(value) {
// only maps and object hashes
var bool = value !== null && value !== undefined && typeof value === 'object' && !Array.isArray(value);
if (Set) {

@@ -308,3 +288,2 @@ return bool && !(value instanceof Set);

}
exports.mapping = mapping;
'use strict';
var nodes = require('./nodes');
var lib = require('./lib');
var sym = 0;
function gensym() {
return 'hole_' + sym++;
} // copy-on-write version of map
}
// copy-on-write version of map
function mapCOW(arr, func) {
var res = null;
for (var i = 0; i < arr.length; i++) {
var item = func(arr[i]);
if (item !== arr[i]) {

@@ -24,10 +19,7 @@ if (!res) {

}
res[i] = item;
}
}
return res || arr;
}
function walk(ast, func, depthFirst) {

@@ -37,6 +29,4 @@ if (!(ast instanceof nodes.Node)) {

}
if (!depthFirst) {
var astT = func(ast);
if (astT && astT !== ast) {

@@ -46,3 +36,2 @@ return astT;

}
if (ast instanceof nodes.NodeList) {

@@ -52,3 +41,2 @@ var children = mapCOW(ast.children, function (node) {

});
if (children !== ast.children) {

@@ -62,3 +50,2 @@ ast = new nodes[ast.typename](ast.lineno, ast.colno, children);

});
if (args !== ast.args || contentArgs !== ast.contentArgs) {

@@ -74,3 +61,2 @@ ast = new nodes[ast.typename](ast.extName, ast.prop, args, contentArgs);

});
if (propsT !== props) {

@@ -83,10 +69,7 @@ ast = new nodes[ast.typename](ast.lineno, ast.colno);

}
return depthFirst ? func(ast) || ast : ast;
}
function depthWalk(ast, func) {
return walk(ast, func, true);
}
function _liftFilters(node, asyncFilters, prop) {

@@ -96,3 +79,2 @@ var children = [];

var symbol;
if (descNode instanceof nodes.Block) {

@@ -104,6 +86,4 @@ return descNode;

}
return symbol;
});
if (prop) {

@@ -114,3 +94,2 @@ node[prop] = walked;

}
if (children.length) {

@@ -123,3 +102,2 @@ children.push(node);

}
function liftFilters(ast, asyncFilters) {

@@ -142,3 +120,2 @@ return depthWalk(ast, function (node) {

}
function liftSuper(ast) {

@@ -149,3 +126,2 @@ return walk(ast, function (blockNode) {

}
var hasSuper = false;

@@ -160,3 +136,2 @@ var symbol = gensym();

});
if (hasSuper) {

@@ -167,3 +142,2 @@ blockNode.body.children.unshift(new nodes.Super(0, 0, blockNode.name, new nodes.Symbol(0, 0, symbol)));

}
function convertStatements(ast) {

@@ -174,14 +148,11 @@ return depthWalk(ast, function (node) {

}
var async = false;
walk(node, function (child) {
if (child instanceof nodes.FilterAsync || child instanceof nodes.IfAsync || child instanceof nodes.AsyncEach || child instanceof nodes.AsyncAll || child instanceof nodes.CallExtensionAsync) {
async = true; // Stop iterating by returning the node
async = true;
// Stop iterating by returning the node
return child;
}
return undefined;
});
if (async) {

@@ -194,14 +165,13 @@ if (node instanceof nodes.If) {

}
return undefined;
});
}
function cps(ast, asyncFilters) {
return convertStatements(liftSuper(liftFilters(ast, asyncFilters)));
}
function transform(ast, asyncFilters) {
return cps(ast, asyncFilters || []);
} // var parser = require('./parser');
}
// var parser = require('./parser');
// var src = 'hello {% foo %}{% endfoo %} end';

@@ -211,5 +181,4 @@ // var ast = transform(parser.parse(src, [new FooExtension()]), ['bar']);

module.exports = {
transform: transform
};
'use strict';
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var Loader = require('./loader');
var _require = require('./precompiled-loader.js'),
PrecompiledLoader = _require.PrecompiledLoader;
PrecompiledLoader = _require.PrecompiledLoader;
var WebLoader = /*#__PURE__*/function (_Loader) {
_inheritsLoose(WebLoader, _Loader);
function WebLoader(baseURL, opts) {
var _this;
_this = _Loader.call(this) || this;
_this.baseURL = baseURL || '.';
opts = opts || {}; // By default, the cache is turned off because there's no way
opts = opts || {};
// By default, the cache is turned off because there's no way
// to "watch" templates over HTTP, so they are re-downloaded
// and compiled each time. (Remember, PRECOMPILE YOUR
// TEMPLATES in production!)
_this.useCache = !!opts.useCache;
_this.useCache = !!opts.useCache; // We default `async` to false so that the simple synchronous
// We default `async` to false so that the simple synchronous
// API can be used when you aren't doing anything async in

@@ -30,16 +27,11 @@ // your templates (which is most of the time). This performs a

// happen in development. PRECOMPILE YOUR TEMPLATES.
_this.async = !!opts.async;
return _this;
}
var _proto = WebLoader.prototype;
_proto.resolve = function resolve(from, to) {
throw new Error('relative templates not support in the browser yet');
};
_proto.getSource = function getSource(name, cb) {
var _this2 = this;
var useCache = this.useCache;

@@ -62,5 +54,3 @@ var result;

};
_this2.emit('load', name, result);
if (cb) {

@@ -70,9 +60,9 @@ cb(null, result);

}
}); // if this WebLoader isn't running asynchronously, the
});
// if this WebLoader isn't running asynchronously, the
// fetch above would actually run sync and we'll have a
// result here
return result;
};
_proto.fetch = function fetch(url, cb) {

@@ -83,10 +73,7 @@ // Only in the browser please

}
var ajax = new XMLHttpRequest();
var loading = true;
ajax.onreadystatechange = function () {
if (ajax.readyState === 4 && loading) {
loading = false;
if (ajax.status === 0 || ajax.status === 200) {

@@ -102,3 +89,2 @@ cb(null, ajax.responseText);

};
url += (url.indexOf('?') === -1 ? '?' : '&') + 's=' + new Date().getTime();

@@ -108,6 +94,4 @@ ajax.open('GET', url, this.async);

};
return WebLoader;
}(Loader);
module.exports = {

@@ -114,0 +98,0 @@ WebLoader: WebLoader,

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc