@kosatyi/ejs 0.0.27 → 0.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ejs.cjs CHANGED
@@ -723,6 +723,7 @@ var init = function init(options) {
723
723
  * @module ejs
724
724
  */
725
725
  var config = {};
726
+ var methodsRegistry = {};
726
727
  configSchema(config, options || {});
727
728
  var context = new Context(config);
728
729
  var compiler = new Compiler(config);
@@ -763,7 +764,7 @@ var init = function init(options) {
763
764
  });
764
765
  };
765
766
  var helpers = function helpers(methods) {
766
- context.helpers(extend(callbacks, methods || {}));
767
+ context.helpers(extend(methodsRegistry, methods || {}));
767
768
  };
768
769
  var __express = function __express(name, options, callback) {
769
770
  if (isFunction(options)) {
package/dist/ejs.js CHANGED
@@ -718,6 +718,7 @@
718
718
  * @module ejs
719
719
  */
720
720
  var config = {};
721
+ var methodsRegistry = {};
721
722
  configSchema(config, options || {});
722
723
  var context = new Context(config);
723
724
  var compiler = new Compiler(config);
@@ -758,7 +759,7 @@
758
759
  });
759
760
  };
760
761
  var helpers = function helpers(methods) {
761
- context.helpers(extend(callbacks, methods || {}));
762
+ context.helpers(extend(methodsRegistry, methods || {}));
762
763
  };
763
764
  var __express = function __express(name, options, callback) {
764
765
  if (isFunction(options)) {
package/dist/ejs.min.js CHANGED
@@ -1 +1 @@
1
- !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).ejs={})}(this,(function(t){"use strict";var n={},e={export:"ejs.precompiled",cache:!0,path:"views",resolver:null,extension:"ejs",withObject:!0,vars:{SCOPE:"ejs",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},r=function(){var t=[].slice.call(arguments),n=t.shift();return t.filter(n).pop()},i=function(t){return"function"==typeof t},o=function(t){return"string"==typeof t},c=function(t){return"boolean"==typeof t},u="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),s=function(){return u},a={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},f={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},h=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},l=h(f),p=h(a),v=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(""+t).replace(l,(function(t){return f[t]}))},d=function(t,n,e){return null==(e=t)?"":n?v(e):e},g=function(t,n){var e=t,r=n.split("."),i=r.pop();return r.forEach((function(t){e=e[t]=e[t]||{}})),[e,i]},m=function(t,n){var e=t.split(".").pop();return e!==n&&(t=[t,n].join(".")),t},y=function(){for(var t=arguments.length,n=new Array(t),e=0;e<t;e++)n[e]=arguments[e];var r=n.shift();return n.filter((function(t){return t})).reduce((function(t,n){return Object.assign(t,n)}),r)},b=function(){},w=function(t,n){var e;for(e in t)k(t,e)&&n(t[e],e,t)},j=function(t,n){return function(t,n,e){var r=t instanceof Array,i=r?[]:{};return w(t,(function(t,e,o){var c=n(t,e,o);void 0!==c&&(r?i.push(c):i[e]=c)})),i}(t,(function(t,e){if(-1===n.indexOf(e))return t}))},x=function(t,n,e){return Promise.resolve(t).then(n.bind(e))},k=function(t,n){return t&&t.hasOwnProperty(n)},E=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],O=" ",F='"',P="/",S="<",B=">",R=function(t,n,e){var r=[],i=-1===E.indexOf(t),o=function(t,n,e){var r=[];return w(t,(function(t,e,i){var o=n(t,e,i);void 0!==o&&r.push(o)})),r}(n,(function(t,n){if(null!=t)return[v(n),[F,v(t),F].join("")].join("=")})).join(O);return r.push([S,t,O,o,B].join("")),e&&r.push(e instanceof Array?e.join(""):e),i&&r.push([S,P,t,B].join("")),r.join("")};function $(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function T(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,A(r.key),r)}}function U(t,n,e){return n&&T(t.prototype,n),e&&T(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function A(t){var n=function(t,n){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,n||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"==typeof n?n:String(n)}var M=[{symbol:"-",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(t){return"')\n/**".concat(t,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(t){return"')\n".concat(t.trim(),"\n").concat(this.BUFFER,"('")}}],_=function(){function t(n){$(this,t),this.configure(n)}return U(t,[{key:"configure",value:function(t){var n=this;this.withObject=t.withObject,this.token=t.token,this.vars=t.vars,this.matches=[],this.formats=[],this.slurp={match:"[ \\t]*",start:[this.token.start,"_"],end:["_",this.token.end]},M.forEach((function(t){n.matches.push(n.token.start.concat(t.symbol).concat(n.token.regex).concat(n.token.end)),n.formats.push(t.format.bind(n.vars))})),this.regex=new RegExp(this.matches.join("|").concat("|$"),"g"),this.slurpStart=new RegExp([this.slurp.match,this.slurp.start].join(""),"gm"),this.slurpEnd=new RegExp([this.slurp.end,this.slurp.match].join(""),"gm")}},{key:"compile",value:function(t,n){var e=this,r=this.vars,i=r.SCOPE,o=r.SAFE,c=r.BUFFER;t=(t=t.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")).replace(this.slurpStart,this.slurp.start).replace(this.slurpEnd,this.slurp.end);var u,s,f,h="".concat(c,"('");u=this.regex,s=function(n,r,i){h+=(""+t.slice(r,i)).replace(p,(function(t){return"\\"+a[t]})),n.forEach((function(t,n){t&&(h+=e.formats[n](t))}))},f=0,t.replace(u,(function(){var t=[].slice.call(arguments,0,-1),n=t.pop(),e=t.shift();return s(t,f,n),f=n+e.length,e})),h="try{".concat(h+="');","}catch(e){console.info(e)}"),this.withObject&&(h="with(".concat(i,"){").concat(h,"}")),h="".concat(c,".start();").concat(h,"return ").concat(c,".end();"),h+="\n//# sourceURL=".concat(n);var l=null;try{(l=new Function(i,c,o,h)).source="(function(".concat(i,",").concat(c,",").concat(o,"){\n").concat(h,"\n})")}catch(t){throw t.filename=n,t.source=h,t}return l}}]),t}(),L=function(){function t(n){$(this,t),this.configure(n)}return U(t,[{key:"configure",value:function(t){this.namespace=t.export,this.useStrict=!1===t.withObject}},{key:"wrapper",value:function(t){var n="";return n+="(function(global,factory){",n+='typeof exports === "object" && typeof module !== "undefined" ?',n+="module.exports = factory():",n+='typeof define === "function" && define.amd ? define(factory):',n+='(global = typeof globalThis !== "undefined" ? globalThis:',n+='global || self,global["'+this.namespace+'"] = factory())',n+="})(this,(function(){",this.useStrict&&(n+="'use strict';\n"),n+="var list = {};\n",t.forEach((function(t){n+="list["+JSON.stringify(t.name)+"]="+String(t.content)+";\n"})),n+="return list;}));\n"}}]),t}(),C=function(t){return fetch(t).then((function(t){return t.text()}))},N=function(t){return new Promise((function(e,r){n.readFile(t,(function(t,n){t?r(t):e(n.toString())}))}))},q=function(){function t(n,e,r){$(this,t),this.cache=e,this.compiler=r,this.configure(n)}return U(t,[{key:"configure",value:function(t){this.path=t.path,this.resolver=i(t.resolver)?t.resolver:s()?N:C}},{key:"resolve",value:function(t){return this.resolver(function(t,n){return(n=[t,n].join("/")).replace(/\/\//g,"/")}(this.path,t))}},{key:"result",value:function(t,n){return this.cache.set(n,t),t}},{key:"get",value:function(t){var n=this;if(this.cache.exist(t))return this.cache.resolve(t);var e=this.resolve(t).then((function(e){return n.result(n.compiler.compile(e,t),t)}));return this.result(e,t)}}]),t}(),D=function(t){return Promise.all(t).then((function(t){return t.join("")}))},K=function(){function t(n){$(this,t),this.configure(n)}return U(t,[{key:"configure",value:function(t){var n=t.vars,e=n.EXTEND,r=n.LAYOUT,c=n.BLOCKS,u=n.BUFFER,s=n.MACRO;function a(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),y(this,t)}this.create=function(t){return new a(t)},this.helpers=function(t){y(a.prototype,t)},a.helpers=function(t){y(a.prototype,t)},a.defineProp=a.method=function(t,n){var e=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];Object.defineProperty(a.prototype,t,{value:n,writable:e,configurable:r,enumerable:i})},a.defineProp(u,function(){var t=[],n=[];function e(t){n.push(t)}return e.start=function(){n=[]},e.backup=function(){t.push(n.concat()),n=[]},e.restore=function(){var e=n.concat();return n=t.pop(),D(e)},e.error=function(t){throw t},e.end=function(){return D(n)},e}()),a.defineProp(c,{},!0),a.defineProp(s,{},!0),a.defineProp(r,!1,!0),a.defineProp(e,!1,!0),a.method("initBlocks",(function(){this[c]={}})),a.method("initMacro",(function(){this[s]={}})),a.method("getMacro",(function(){return this[s]})),a.method("getBuffer",(function(){return this[u]})),a.method("getBlocks",(function(){return this[c]})),a.method("setExtend",(function(t){this[e]=t})),a.method("getExtend",(function(){return this[e]})),a.method("setLayout",(function(t){this[r]=t})),a.method("getLayout",(function(){return this[r]})),a.method("clone",(function(t){var n=[r,e,u];return!0===t&&n.push(c),j(this,n)})),a.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),a.method("echo",(function(){var t=this.getBuffer(),n=[].slice.call(arguments);n.forEach(t)})),a.method("fn",(function(t){var n=this.getBuffer(),e=this;return function(){return n.backup(),i(t)&&t.apply(e,arguments),n.restore()}})),a.method("get",(function(t,n){var e=g(this,t),r=e.shift(),i=e.pop();return k(r,i)?r[i]:n})),a.method("set",(function(t,n){var e=g(this,t),r=e.shift(),i=e.pop();return this.getExtend()&&k(r,i)?r[i]:r[i]=n})),a.method("macro",(function(t,n){var e=this.getMacro(),r=this.fn(n),i=this;e[t]=function(){return i.echo(r.apply(void 0,arguments))}})),a.method("call",(function(t){var n=this.getMacro(),e=n[t],r=[].slice.call(arguments,1);if(i(e))return e.apply(e,r)})),a.method("block",(function(t,n){var e=this,r=this.getBlocks();if(r[t]=r[t]||[],r[t].push(this.fn(n)),!this.getExtend()){var i=Object.assign([],r[t]),o=function(){return i.shift()};this.echo(o()(function t(){var n=o();return n?function(){e.echo(n(t()))}:b}()))}})),a.method("include",(function(t,n,e){var r=!1===e?{}:this.clone(!0),i=y(r,n||{}),o=this.render(t,i);this.echo(o)})),a.method("use",(function(t,n){var e=this.require(t);this.echo(x(e,(function(t){var e=this.getMacro();w(t,(function(t,r){e[[n,r].join(".")]=t}))}),this))})),a.method("async",(function(t,n){this.echo(x(t,(function(t){return this.fn(n)(t)}),this))})),a.method("el",(function(t,n,e){i(e)&&(e=this.fn(e)()),this.echo(x(e,(function(e){return R(t,n,e)}),this))})),a.method("each",(function(t,n){o(t)&&(t=this.get(t,[])),w(t,n)}))}}]),t}(),X="undefined"!=typeof globalThis?globalThis:window||self,Y=function(){function t(n){var e,r,i;$(this,t),e=this,i={},(r=A(r="list"))in e?Object.defineProperty(e,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[r]=i,this.configure(n),!1===s()&&this.load(X[this.namespace])}return U(t,[{key:"configure",value:function(t){this.list={},this.namespace=t.export}},{key:"load",value:function(t){return y(this.list,t),this}},{key:"exist",value:function(t){return k(this.list,t)}},{key:"get",value:function(t){return this.list[t]}},{key:"remove",value:function(t){delete this.list[t]}},{key:"resolve",value:function(t){return Promise.resolve(this.get(t))}},{key:"set",value:function(t,n){return this.list[t]=n,this}}]),t}(),J=function(t,n){y(t,{export:r(o,e.export,n.export),path:r(o,e.path,n.path),resolver:r(i,e.resolver,n.resolver),extension:r(o,e.extension,n.extension),withObject:r(c,e.withObject,n.withObject),token:y({},e.token,n.token),vars:y({},e.vars,n.vars)})},V=function t(u){var s={};J(s,u||{});var a=new K(s),f=new _(s),h=new L(s),l=new Y(s),p=new q(s,l,f),v=function(t){J(s,t),a.configure(s),f.configure(s),h.configure(s),l.configure(s),p.configure(s)},g=function(t,n){return p.get(t).then((function(t){return t.call(n,n,n.getBuffer(),d)}))},b=function(t,n){var e=m(t,s.extension),r=a.create(n);return g(e,r).then((function(t){if(r.getExtend()){r.setExtend(!1);var n=r.getLayout(),e=r.clone();return b(n,e)}return t}))},w=function(t){a.helpers(y(callbacks,t||{}))};return w({require:function(t){return function(t){var n=m(t,s.extension),e=a.create({});return g(n,e).then((function(){return e.getMacro()}))}(t)},render:function(t,n){return b(t,n)}}),{render:b,helpers:w,configure:v,wrapper:function(t){return h.wrapper(t)},compile:function(t,n){return f.compile(t,n)},create:function(n){return t(n)},preload:function(t){return l.load(t)},__express:function(t,u,s){i(u)&&(s=u,u={});var a=y({},(u=u||{}).settings),f=r(o,a.views,e.path),h=r(c,a["view cache"],e.cache),l=y({},a["view options"]),p=n.relative(f,t);return l.path=f,l.cache=h,v(l),b(p,u).then((function(t){s(null,t)})).catch((function(t){s(t)}))}}}({}),z=V.render,G=V.helpers,H=V.configure,I=V.wrapper,Q=V.compile,W=V.create,Z=V.preload,tt=V.__express;t.__express=tt,t.compile=Q,t.configure=H,t.create=W,t.element=R,t.helpers=G,t.preload=Z,t.render=z,t.safeValue=d,t.wrapper=I,Object.defineProperty(t,"__esModule",{value:!0})}));
1
+ !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).ejs={})}(this,(function(t){"use strict";var n={},e={export:"ejs.precompiled",cache:!0,path:"views",resolver:null,extension:"ejs",withObject:!0,vars:{SCOPE:"ejs",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},r=function(){var t=[].slice.call(arguments),n=t.shift();return t.filter(n).pop()},i=function(t){return"function"==typeof t},o=function(t){return"string"==typeof t},c=function(t){return"boolean"==typeof t},u="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),s=function(){return u},a={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},f={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},h=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},l=h(f),p=h(a),v=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(""+t).replace(l,(function(t){return f[t]}))},d=function(t,n,e){return null==(e=t)?"":n?v(e):e},g=function(t,n){var e=t,r=n.split("."),i=r.pop();return r.forEach((function(t){e=e[t]=e[t]||{}})),[e,i]},m=function(t,n){var e=t.split(".").pop();return e!==n&&(t=[t,n].join(".")),t},y=function(){for(var t=arguments.length,n=new Array(t),e=0;e<t;e++)n[e]=arguments[e];var r=n.shift();return n.filter((function(t){return t})).reduce((function(t,n){return Object.assign(t,n)}),r)},b=function(){},w=function(t,n){var e;for(e in t)E(t,e)&&n(t[e],e,t)},j=function(t,n){return function(t,n,e){var r=t instanceof Array,i=r?[]:{};return w(t,(function(t,e,o){var c=n(t,e,o);void 0!==c&&(r?i.push(c):i[e]=c)})),i}(t,(function(t,e){if(-1===n.indexOf(e))return t}))},x=function(t,n,e){return Promise.resolve(t).then(n.bind(e))},E=function(t,n){return t&&t.hasOwnProperty(n)},k=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],O=" ",F='"',P="/",S="<",B=">",R=function(t,n,e){var r=[],i=-1===k.indexOf(t),o=function(t,n,e){var r=[];return w(t,(function(t,e,i){var o=n(t,e,i);void 0!==o&&r.push(o)})),r}(n,(function(t,n){if(null!=t)return[v(n),[F,v(t),F].join("")].join("=")})).join(O);return r.push([S,t,O,o,B].join("")),e&&r.push(e instanceof Array?e.join(""):e),i&&r.push([S,P,t,B].join("")),r.join("")};function $(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}function T(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,A(r.key),r)}}function U(t,n,e){return n&&T(t.prototype,n),e&&T(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function A(t){var n=function(t,n){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,n||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"==typeof n?n:String(n)}var M=[{symbol:"-",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(t){return"')\n/**".concat(t,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(t){return"')\n".concat(t.trim(),"\n").concat(this.BUFFER,"('")}}],_=function(){function t(n){$(this,t),this.configure(n)}return U(t,[{key:"configure",value:function(t){var n=this;this.withObject=t.withObject,this.token=t.token,this.vars=t.vars,this.matches=[],this.formats=[],this.slurp={match:"[ \\t]*",start:[this.token.start,"_"],end:["_",this.token.end]},M.forEach((function(t){n.matches.push(n.token.start.concat(t.symbol).concat(n.token.regex).concat(n.token.end)),n.formats.push(t.format.bind(n.vars))})),this.regex=new RegExp(this.matches.join("|").concat("|$"),"g"),this.slurpStart=new RegExp([this.slurp.match,this.slurp.start].join(""),"gm"),this.slurpEnd=new RegExp([this.slurp.end,this.slurp.match].join(""),"gm")}},{key:"compile",value:function(t,n){var e=this,r=this.vars,i=r.SCOPE,o=r.SAFE,c=r.BUFFER;t=(t=t.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")).replace(this.slurpStart,this.slurp.start).replace(this.slurpEnd,this.slurp.end);var u,s,f,h="".concat(c,"('");u=this.regex,s=function(n,r,i){h+=(""+t.slice(r,i)).replace(p,(function(t){return"\\"+a[t]})),n.forEach((function(t,n){t&&(h+=e.formats[n](t))}))},f=0,t.replace(u,(function(){var t=[].slice.call(arguments,0,-1),n=t.pop(),e=t.shift();return s(t,f,n),f=n+e.length,e})),h="try{".concat(h+="');","}catch(e){console.info(e)}"),this.withObject&&(h="with(".concat(i,"){").concat(h,"}")),h="".concat(c,".start();").concat(h,"return ").concat(c,".end();"),h+="\n//# sourceURL=".concat(n);var l=null;try{(l=new Function(i,c,o,h)).source="(function(".concat(i,",").concat(c,",").concat(o,"){\n").concat(h,"\n})")}catch(t){throw t.filename=n,t.source=h,t}return l}}]),t}(),L=function(){function t(n){$(this,t),this.configure(n)}return U(t,[{key:"configure",value:function(t){this.namespace=t.export,this.useStrict=!1===t.withObject}},{key:"wrapper",value:function(t){var n="";return n+="(function(global,factory){",n+='typeof exports === "object" && typeof module !== "undefined" ?',n+="module.exports = factory():",n+='typeof define === "function" && define.amd ? define(factory):',n+='(global = typeof globalThis !== "undefined" ? globalThis:',n+='global || self,global["'+this.namespace+'"] = factory())',n+="})(this,(function(){",this.useStrict&&(n+="'use strict';\n"),n+="var list = {};\n",t.forEach((function(t){n+="list["+JSON.stringify(t.name)+"]="+String(t.content)+";\n"})),n+="return list;}));\n"}}]),t}(),C=function(t){return fetch(t).then((function(t){return t.text()}))},N=function(t){return new Promise((function(e,r){n.readFile(t,(function(t,n){t?r(t):e(n.toString())}))}))},q=function(){function t(n,e,r){$(this,t),this.cache=e,this.compiler=r,this.configure(n)}return U(t,[{key:"configure",value:function(t){this.path=t.path,this.resolver=i(t.resolver)?t.resolver:s()?N:C}},{key:"resolve",value:function(t){return this.resolver(function(t,n){return(n=[t,n].join("/")).replace(/\/\//g,"/")}(this.path,t))}},{key:"result",value:function(t,n){return this.cache.set(n,t),t}},{key:"get",value:function(t){var n=this;if(this.cache.exist(t))return this.cache.resolve(t);var e=this.resolve(t).then((function(e){return n.result(n.compiler.compile(e,t),t)}));return this.result(e,t)}}]),t}(),D=function(t){return Promise.all(t).then((function(t){return t.join("")}))},K=function(){function t(n){$(this,t),this.configure(n)}return U(t,[{key:"configure",value:function(t){var n=t.vars,e=n.EXTEND,r=n.LAYOUT,c=n.BLOCKS,u=n.BUFFER,s=n.MACRO;function a(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),y(this,t)}this.create=function(t){return new a(t)},this.helpers=function(t){y(a.prototype,t)},a.helpers=function(t){y(a.prototype,t)},a.defineProp=a.method=function(t,n){var e=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];Object.defineProperty(a.prototype,t,{value:n,writable:e,configurable:r,enumerable:i})},a.defineProp(u,function(){var t=[],n=[];function e(t){n.push(t)}return e.start=function(){n=[]},e.backup=function(){t.push(n.concat()),n=[]},e.restore=function(){var e=n.concat();return n=t.pop(),D(e)},e.error=function(t){throw t},e.end=function(){return D(n)},e}()),a.defineProp(c,{},!0),a.defineProp(s,{},!0),a.defineProp(r,!1,!0),a.defineProp(e,!1,!0),a.method("initBlocks",(function(){this[c]={}})),a.method("initMacro",(function(){this[s]={}})),a.method("getMacro",(function(){return this[s]})),a.method("getBuffer",(function(){return this[u]})),a.method("getBlocks",(function(){return this[c]})),a.method("setExtend",(function(t){this[e]=t})),a.method("getExtend",(function(){return this[e]})),a.method("setLayout",(function(t){this[r]=t})),a.method("getLayout",(function(){return this[r]})),a.method("clone",(function(t){var n=[r,e,u];return!0===t&&n.push(c),j(this,n)})),a.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),a.method("echo",(function(){var t=this.getBuffer(),n=[].slice.call(arguments);n.forEach(t)})),a.method("fn",(function(t){var n=this.getBuffer(),e=this;return function(){return n.backup(),i(t)&&t.apply(e,arguments),n.restore()}})),a.method("get",(function(t,n){var e=g(this,t),r=e.shift(),i=e.pop();return E(r,i)?r[i]:n})),a.method("set",(function(t,n){var e=g(this,t),r=e.shift(),i=e.pop();return this.getExtend()&&E(r,i)?r[i]:r[i]=n})),a.method("macro",(function(t,n){var e=this.getMacro(),r=this.fn(n),i=this;e[t]=function(){return i.echo(r.apply(void 0,arguments))}})),a.method("call",(function(t){var n=this.getMacro(),e=n[t],r=[].slice.call(arguments,1);if(i(e))return e.apply(e,r)})),a.method("block",(function(t,n){var e=this,r=this.getBlocks();if(r[t]=r[t]||[],r[t].push(this.fn(n)),!this.getExtend()){var i=Object.assign([],r[t]),o=function(){return i.shift()};this.echo(o()(function t(){var n=o();return n?function(){e.echo(n(t()))}:b}()))}})),a.method("include",(function(t,n,e){var r=!1===e?{}:this.clone(!0),i=y(r,n||{}),o=this.render(t,i);this.echo(o)})),a.method("use",(function(t,n){var e=this.require(t);this.echo(x(e,(function(t){var e=this.getMacro();w(t,(function(t,r){e[[n,r].join(".")]=t}))}),this))})),a.method("async",(function(t,n){this.echo(x(t,(function(t){return this.fn(n)(t)}),this))})),a.method("el",(function(t,n,e){i(e)&&(e=this.fn(e)()),this.echo(x(e,(function(e){return R(t,n,e)}),this))})),a.method("each",(function(t,n){o(t)&&(t=this.get(t,[])),w(t,n)}))}}]),t}(),X="undefined"!=typeof globalThis?globalThis:window||self,Y=function(){function t(n){var e,r,i;$(this,t),e=this,i={},(r=A(r="list"))in e?Object.defineProperty(e,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[r]=i,this.configure(n),!1===s()&&this.load(X[this.namespace])}return U(t,[{key:"configure",value:function(t){this.list={},this.namespace=t.export}},{key:"load",value:function(t){return y(this.list,t),this}},{key:"exist",value:function(t){return E(this.list,t)}},{key:"get",value:function(t){return this.list[t]}},{key:"remove",value:function(t){delete this.list[t]}},{key:"resolve",value:function(t){return Promise.resolve(this.get(t))}},{key:"set",value:function(t,n){return this.list[t]=n,this}}]),t}(),J=function(t,n){y(t,{export:r(o,e.export,n.export),path:r(o,e.path,n.path),resolver:r(i,e.resolver,n.resolver),extension:r(o,e.extension,n.extension),withObject:r(c,e.withObject,n.withObject),token:y({},e.token,n.token),vars:y({},e.vars,n.vars)})},V=function t(u){var s={},a={};J(s,u||{});var f=new K(s),h=new _(s),l=new L(s),p=new Y(s),v=new q(s,p,h),g=function(t){J(s,t),f.configure(s),h.configure(s),l.configure(s),p.configure(s),v.configure(s)},b=function(t,n){return v.get(t).then((function(t){return t.call(n,n,n.getBuffer(),d)}))},w=function(t,n){var e=m(t,s.extension),r=f.create(n);return b(e,r).then((function(t){if(r.getExtend()){r.setExtend(!1);var n=r.getLayout(),e=r.clone();return w(n,e)}return t}))},j=function(t){f.helpers(y(a,t||{}))};return j({require:function(t){return function(t){var n=m(t,s.extension),e=f.create({});return b(n,e).then((function(){return e.getMacro()}))}(t)},render:function(t,n){return w(t,n)}}),{render:w,helpers:j,configure:g,wrapper:function(t){return l.wrapper(t)},compile:function(t,n){return h.compile(t,n)},create:function(n){return t(n)},preload:function(t){return p.load(t)},__express:function(t,u,s){i(u)&&(s=u,u={});var a=y({},(u=u||{}).settings),f=r(o,a.views,e.path),h=r(c,a["view cache"],e.cache),l=y({},a["view options"]),p=n.relative(f,t);return l.path=f,l.cache=h,g(l),w(p,u).then((function(t){s(null,t)})).catch((function(t){s(t)}))}}}({}),z=V.render,G=V.helpers,H=V.configure,I=V.wrapper,Q=V.compile,W=V.create,Z=V.preload,tt=V.__express;t.__express=tt,t.compile=Q,t.configure=H,t.create=W,t.element=R,t.helpers=G,t.preload=Z,t.render=z,t.safeValue=d,t.wrapper=I,Object.defineProperty(t,"__esModule",{value:!0})}));
package/dist/ejs.mjs CHANGED
@@ -726,6 +726,7 @@ const init = (options) => {
726
726
  * @module ejs
727
727
  */
728
728
  const config = {};
729
+ const methodsRegistry = {};
729
730
 
730
731
  configSchema(config, options || {});
731
732
 
@@ -773,7 +774,7 @@ const init = (options) => {
773
774
  };
774
775
 
775
776
  const helpers = (methods) => {
776
- context.helpers(extend(callbacks, methods || {}));
777
+ context.helpers(extend(methodsRegistry, methods || {}));
777
778
  };
778
779
 
779
780
  const __express = (name, options, callback) => {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@kosatyi/ejs",
3
3
  "description": "EJS Templates",
4
4
  "homepage": "https://github.com/kosatyi/ejs",
5
- "version": "0.0.27",
5
+ "version": "0.0.28",
6
6
  "main": "dist/ejs.cjs",
7
7
  "module": "dist/ejs.mjs",
8
8
  "browser": "dist/ejs.js",