@kosatyi/ejs 0.0.56 → 0.0.57

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/cjs/index.js CHANGED
@@ -764,7 +764,7 @@ var EJS = /*#__PURE__*/function () {
764
764
  function EJS() {
765
765
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
766
766
  _classCallCheck(this, EJS);
767
- _defineProperty(this, "export", ['cache', 'render', 'require', 'helpers', 'configure', 'preload', 'compiler', '__express']);
767
+ _defineProperty(this, "export", ['cache', 'render', 'require', 'helpers', 'configure', 'preload', 'compile', 'create', '__express']);
768
768
  this.config = {};
769
769
  this.scope = {};
770
770
  configSchema(this.config, options);
package/dist/esm/index.js CHANGED
@@ -800,7 +800,8 @@ class EJS {
800
800
  'helpers',
801
801
  'configure',
802
802
  'preload',
803
- 'compiler',
803
+ 'compile',
804
+ 'create',
804
805
  '__express',
805
806
  ]
806
807
  constructor(options = {}) {
package/dist/umd/index.js CHANGED
@@ -767,7 +767,7 @@
767
767
  function EJS() {
768
768
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
769
769
  _classCallCheck(this, EJS);
770
- _defineProperty(this, "export", ['cache', 'render', 'require', 'helpers', 'configure', 'preload', 'compiler', '__express']);
770
+ _defineProperty(this, "export", ['cache', 'render', 'require', 'helpers', 'configure', 'preload', 'compile', 'create', '__express']);
771
771
  this.config = {};
772
772
  this.scope = {};
773
773
  configSchema(this.config, options);
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ejs={})}(this,(function(t){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,c(i.key),i)}}function r(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function o(t,e,n){return(e=c(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function c(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var u=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},s=function(t){return"function"==typeof t},h=function(t){return"string"==typeof t},a=function(t){return"boolean"==typeof t},f=function(t){return"object"===e(t)},l=function(t){return void 0===t},p="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),v=function(){return p},d={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},m={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},g=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},y=g(m),b=g(d),k=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(y,(function(t){return m[t]}))},w=function(t,e,n){return null==(n=t)?"":e?k(n):n},x=function(t,e){var n=t,i=e.split("."),r=i.pop();return i.forEach((function(t){n=n[t]=n[t]||{}})),[n,r]},j=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},E=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=e.shift();return e.filter((function(t){return t})).reduce((function(t,e){return Object.assign(t,e)}),i)},O=function(){},F=function(t,e){var n;for(n in t)P(t,n)&&e(t[n],n,t)},S=function(t,e){return function(t,e,n){var i=t instanceof Array,r=i?[]:{};return F(t,(function(t,n,o){var c=e(t,n,o);!1===l(c)&&(i?r.push(c):r[n]=c)})),r}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},B=function(t,e,n){return Promise.resolve(t).then(e.bind(n))},P=function(t,e){return t&&t.hasOwnProperty(e)},R={export:"ejsPrecompiled",watch:!1,chokidar:null,path:"views",resolver:null,extension:"ejs",rmWhitespace:!0,withObject:!0,vars:{SCOPE:"ejs",COMPONENT:"ui",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},$=function(t,e){E(t,{path:u(h,R.path,t.path,e.path),export:u(h,R.export,t.export,e.export),resolver:u(s,R.resolver,t.resolver,e.resolver),extension:u(h,R.extension,t.extension,e.extension),withObject:u(a,R.withObject,t.withObject,e.withObject),rmWhitespace:u(a,R.rmWhitespace,t.rmWhitespace,e.rmWhitespace),watch:u(a,R.watch,t.watch,e.watch),chokidar:u(f,R.export,t.export,e.export),token:E({},R.token,t.token,e.token),vars:E({},R.vars,t.vars,e.vars)})},T={},C=function(t,e){return e=(e=[t,e].join("/")).replace(/\/\//g,"/")},M=function(t,e){return fetch(C(t,e)).then((function(t){return t.text()}))},U=function(t,e){return new Promise((function(n,i){T.readFile(C(t,e),(function(t,e){t?i(t):n(e.toString())}))}))},A=function(){function t(e,i,r){n(this,t),this.cache=i,this.watcher={unwatch:function(){},on:function(){}},this.compiler=r,this.configure(e)}return r(t,[{key:"configure",value:function(t){var e=this;this.path=t.path,this.chokidar=t.chokidar,this.resolver=s(t.resolver)?t.resolver:v()?U:M,t.watch&&v()&&(this.watcher&&this.watcher.unwatch("."),this.chokidar&&(this.watcher=this.chokidar.watch(".",{cwd:this.path}).on("change",(function(t){e.cache.remove(t)}))))}},{key:"resolve",value:function(t){return this.resolver(this.path,t)}},{key:"result",value:function(t,e){return this.cache.set(t,e),e}},{key:"compile",value:function(t,e){return s(t)?t:this.compiler.compile(t,e)}},{key:"get",value:function(t){var e=this;if(this.cache.exist(t))return this.cache.resolve(t);var n=this.resolve(t).then((function(n){return e.result(t,e.compile(n,t))}));return this.result(t,n)}}]),t}(),_=[{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,"('")}}],L=function(){function t(e){n(this,t),this.configure(e)}return r(t,[{key:"configure",value:function(t){var e=this;this.withObject=t.withObject,this.rmWhitespace=t.rmWhitespace,this.token=t.token,this.vars=t.vars,this.matches=[],this.formats=[],this.slurp={match:"[ \\t]*",start:[this.token.start,"_"],end:["_",this.token.end]},_.forEach((function(t){e.matches.push(e.token.start.concat(t.symbol).concat(e.token.regex).concat(e.token.end)),e.formats.push(t.format.bind(e.vars))})),this.regex=new RegExp(this.matches.join("|").concat("|$"),"g"),this.slurpStart=new RegExp([this.slurp.match,this.slurp.start.join("")].join(""),"gm"),this.slurpEnd=new RegExp([this.slurp.end.join(""),this.slurp.match].join(""),"gm")}},{key:"truncate",value:function(t){return t&&t.replace(/^(?:\r\n|\r|\n)/,"")}},{key:"compile",value:function(t,e){var n=this,i=this.vars,r=i.SCOPE,o=i.SAFE,c=i.BUFFER,u=i.COMPONENT;this.rmWhitespace&&(t=t.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=t.replace(this.slurpStart,this.token.start).replace(this.slurpEnd,this.token.end);var s,h,a,f="".concat(c,"('");s=this.regex,h=function(e,i,r){f+=(""+t.slice(i,r)).replace(b,(function(t){return"\\"+d[t]})),e.forEach((function(t,e){t&&(f+=n.formats[e](t))}))},a=0,t.replace(s,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return h(t,a,e),a=e+n.length,n})),f="try{".concat(f+="');","}catch(e){console.info(e)}"),this.withObject&&(f="with(".concat(r,"){").concat(f,"}")),f="".concat(c,".start();").concat(f,"return ").concat(c,".end();"),f+="\n//# sourceURL=".concat(e);var l=null;try{(l=new Function(r,u,c,o,f)).source="(function(".concat(r,",").concat(u,",").concat(c,",").concat(o,"){\n").concat(f,"\n})")}catch(t){throw t.filename=e,t.source=f,t}return l}}]),t}(),N="undefined"!=typeof globalThis?globalThis:window||self,W=function(){function t(e){n(this,t),o(this,"list",{}),this.configure(e),!1===v()&&this.load(N[this.namespace])}return r(t,[{key:"configure",value:function(t){this.list={},this.namespace=t.export}},{key:"load",value:function(t){return E(this.list,t),this}},{key:"exist",value:function(t){return P(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,e){return this.list[t]=e,this}}]),t}(),q=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],D=" ",K='"',X="/",Y="<",J=">",V=function(t,e,n){var i=[],r=-1===q.indexOf(t),o=function(t,e,n){var i=[];return F(t,(function(t,n,r){var o=e(t,n,r);!1===l(o)&&i.push(o)})),i}(e,(function(t,e){if(null!=t)return[k(e),[K,k(t),K].join("")].join("=")})).join(D);return i.push([Y,t,D,o,J].join("")),n&&i.push(n instanceof Array?n.join(""):n),r&&i.push([Y,X,t,J].join("")),i.join("")},z=function(t){return Promise.all(t).then((function(t){return t.join("")}))},G=function(){function t(e){n(this,t),this.configure(e)}return r(t,[{key:"configure",value:function(t,e){var n=t.vars,i=n.EXTEND,r=n.LAYOUT,o=n.BLOCKS,c=n.BUFFER,u=n.MACRO,a=n.COMPONENT;function f(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),E(this,t)}this.create=function(t){return new f(t)},this.helpers=function(t){E(f.prototype,t)},f.prototype=E({},e||{}),f.define=f.method=function(t,e,n,i,r){return Object.defineProperty(f.prototype,t,{value:e,writable:n||!1,configurable:i||!1,enumerable:r||!1})},f.define(c,function(){var t=[],e=[];function n(t){e.push(t)}return n.start=function(){e=[]},n.backup=function(){t.push(e.concat()),e=[]},n.restore=function(){var n=e.concat();return e=t.pop(),z(n)},n.error=function(t){throw t},n.end=function(){return z(e)},n}()),f.define(o,{},!0),f.define(u,{},!0),f.define(r,!1,!0),f.define(i,!1,!0),f.method("initBlocks",(function(){this[o]={}})),f.method("initMacro",(function(){this[u]={}})),f.method("getMacro",(function(){return this[u]})),f.method("getBuffer",(function(){return this[c]})),f.method("getComponent",(function(){var t=this;return a in t?function(){return t[a].apply(t,arguments)}:function(){console.log("%s function not defined",a)}})),f.method("getBlocks",(function(){return this[o]})),f.method("setExtend",(function(t){this[i]=t})),f.method("getExtend",(function(){return this[i]})),f.method("setLayout",(function(t){this[r]=t})),f.method("getLayout",(function(){return this[r]})),f.method("clone",(function(t){var e=[r,i,c];return!0===t&&e.push(o),S(this,e)})),f.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),f.method("echo",(function(){var t=this.getBuffer();[].slice.call(arguments).forEach(t)})),f.method("fn",(function(t){var e=this.getBuffer(),n=this;return function(){return e.backup(),s(t)&&t.apply(n,arguments),e.restore()}})),f.method("get",(function(t,e){var n=x(this,t),i=n.shift(),r=n.pop();return P(i,r)?i[r]:e})),f.method("set",(function(t,e){var n=x(this,t),i=n.shift(),r=n.pop();return this.getExtend()&&P(i,r)?i[r]:i[r]=e})),f.method("macro",(function(t,e){var n=this.getMacro(),i=this.fn(e),r=this;n[t]=function(){return r.echo(i.apply(void 0,arguments))}})),f.method("call",(function(t){var e=this.getMacro()[t],n=[].slice.call(arguments,1);if(s(e))return e.apply(e,n)})),f.method("block",(function(t,e){var n=this,i=this.getBlocks();if(i[t]=i[t]||[],i[t].push(this.fn(e)),!this.getExtend()){var r=Object.assign([],i[t]),o=function(){return r.shift()};this.echo(o()(function t(){var e=o();return e?function(){n.echo(e(t()))}:O}()))}})),f.method("include",(function(t,e,n){var i=!1===n?{}:this.clone(!0),r=E(i,e||{}),o=this.render(t,r);this.echo(o)})),f.method("use",(function(t,e){var n=this.require(t);this.echo(B(n,(function(t){var n=this.getMacro();F(t,(function(t,i){n[[e,i].join(".")]=t}))}),this))})),f.method("async",(function(t,e){this.echo(B(t,(function(t){return this.fn(e)(t)}),this))})),f.method("node",(function(t,e,n){return V(t,e,n)})),f.method("el",(function(t,e,n){s(n)&&(n=this.fn(n)()),this.echo(B(n,(function(n){return V(t,e,n)}),this))})),f.method("each",(function(t,e){h(t)&&(t=this.get(t,[])),F(t,e)}))}}]),t}(),H=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,t),o(this,"export",["cache","render","require","helpers","configure","preload","compiler","__express"]),this.config={},this.scope={},$(this.config,e),function(t,e){(arguments.length>2&&void 0!==arguments[2]?arguments[2]:[]).forEach((function(n){n in t&&(t[n]=t[n].bind(e))}))}(this,this,this.export),this.context=new G(this.config),this.compiler=new L(this.config),this.cache=new W(this.config),this.template=new A(this.config,this.cache,this.compiler),this.helpers({require:this.require,render:this.render})}return r(t,[{key:"configure",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return $(this.config,t),this.context.configure(this.config,this.scope),this.compiler.configure(this.config),this.cache.configure(this.config),this.template.configure(this.config),this.config}},{key:"output",value:function(t,e){return this.template.get(t).then((function(t){return t.call(e,e,e.getComponent(),e.getBuffer(),w)}))}},{key:"render",value:function(t,e){var n=this,i=j(t,this.config.extension),r=this.context.create(e);return this.output(i,r).then((function(t){if(r.getExtend()){r.setExtend(!1);var e=r.getLayout(),i=r.clone();return n.render(e,i)}return t}))}},{key:"require",value:function(t){var e=j(t,this.config.extension),n=this.context.create({});return this.output(e,n).then((function(){return n.getMacro()}))}},{key:"create",value:function(){return new t(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}},{key:"helpers",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.context.helpers(E(this.scope,t))}},{key:"preload",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.cache.load(t)}},{key:"compile",value:function(t,e){return this.compiler.compile(t,e)}},{key:"__express",value:function(t,e,n){s(e)&&(n=e,e={});var i=E({},(e=e||{}).settings),r=u(h,R.path,i.views),o=u(a,R.cache,i["view cache"]),c=E({},i["view options"]),f=T.relative(r,t);return c.path=r,c.cache=o,this.configure(c),this.render(f,e).then((function(t){n(null,t)})).catch((function(t){n(t)}))}}]),t}(),I=new H({}),Q=I.__express,Z=I.render,tt=I.context,et=I.compile,nt=I.helpers,it=I.preload,rt=I.configure,ot=I.create;t.EJS=H,t.__express=Q,t.compile=et,t.configure=rt,t.context=tt,t.create=ot,t.element=V,t.helpers=nt,t.preload=it,t.render=Z,t.safeValue=w}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ejs={})}(this,(function(t){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,c(i.key),i)}}function r(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function o(t,e,n){return(e=c(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function c(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var u=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},s=function(t){return"function"==typeof t},h=function(t){return"string"==typeof t},a=function(t){return"boolean"==typeof t},f=function(t){return"object"===e(t)},l=function(t){return void 0===t},p="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),v=function(){return p},d={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},m={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},g=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},y=g(m),b=g(d),k=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(y,(function(t){return m[t]}))},w=function(t,e,n){return null==(n=t)?"":e?k(n):n},x=function(t,e){var n=t,i=e.split("."),r=i.pop();return i.forEach((function(t){n=n[t]=n[t]||{}})),[n,r]},j=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},E=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var i=e.shift();return e.filter((function(t){return t})).reduce((function(t,e){return Object.assign(t,e)}),i)},O=function(){},F=function(t,e){var n;for(n in t)P(t,n)&&e(t[n],n,t)},S=function(t,e){return function(t,e,n){var i=t instanceof Array,r=i?[]:{};return F(t,(function(t,n,o){var c=e(t,n,o);!1===l(c)&&(i?r.push(c):r[n]=c)})),r}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},B=function(t,e,n){return Promise.resolve(t).then(e.bind(n))},P=function(t,e){return t&&t.hasOwnProperty(e)},R={export:"ejsPrecompiled",watch:!1,chokidar:null,path:"views",resolver:null,extension:"ejs",rmWhitespace:!0,withObject:!0,vars:{SCOPE:"ejs",COMPONENT:"ui",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},$=function(t,e){E(t,{path:u(h,R.path,t.path,e.path),export:u(h,R.export,t.export,e.export),resolver:u(s,R.resolver,t.resolver,e.resolver),extension:u(h,R.extension,t.extension,e.extension),withObject:u(a,R.withObject,t.withObject,e.withObject),rmWhitespace:u(a,R.rmWhitespace,t.rmWhitespace,e.rmWhitespace),watch:u(a,R.watch,t.watch,e.watch),chokidar:u(f,R.export,t.export,e.export),token:E({},R.token,t.token,e.token),vars:E({},R.vars,t.vars,e.vars)})},T={},C=function(t,e){return e=(e=[t,e].join("/")).replace(/\/\//g,"/")},M=function(t,e){return fetch(C(t,e)).then((function(t){return t.text()}))},U=function(t,e){return new Promise((function(n,i){T.readFile(C(t,e),(function(t,e){t?i(t):n(e.toString())}))}))},A=function(){function t(e,i,r){n(this,t),this.cache=i,this.watcher={unwatch:function(){},on:function(){}},this.compiler=r,this.configure(e)}return r(t,[{key:"configure",value:function(t){var e=this;this.path=t.path,this.chokidar=t.chokidar,this.resolver=s(t.resolver)?t.resolver:v()?U:M,t.watch&&v()&&(this.watcher&&this.watcher.unwatch("."),this.chokidar&&(this.watcher=this.chokidar.watch(".",{cwd:this.path}).on("change",(function(t){e.cache.remove(t)}))))}},{key:"resolve",value:function(t){return this.resolver(this.path,t)}},{key:"result",value:function(t,e){return this.cache.set(t,e),e}},{key:"compile",value:function(t,e){return s(t)?t:this.compiler.compile(t,e)}},{key:"get",value:function(t){var e=this;if(this.cache.exist(t))return this.cache.resolve(t);var n=this.resolve(t).then((function(n){return e.result(t,e.compile(n,t))}));return this.result(t,n)}}]),t}(),_=[{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,"('")}}],L=function(){function t(e){n(this,t),this.configure(e)}return r(t,[{key:"configure",value:function(t){var e=this;this.withObject=t.withObject,this.rmWhitespace=t.rmWhitespace,this.token=t.token,this.vars=t.vars,this.matches=[],this.formats=[],this.slurp={match:"[ \\t]*",start:[this.token.start,"_"],end:["_",this.token.end]},_.forEach((function(t){e.matches.push(e.token.start.concat(t.symbol).concat(e.token.regex).concat(e.token.end)),e.formats.push(t.format.bind(e.vars))})),this.regex=new RegExp(this.matches.join("|").concat("|$"),"g"),this.slurpStart=new RegExp([this.slurp.match,this.slurp.start.join("")].join(""),"gm"),this.slurpEnd=new RegExp([this.slurp.end.join(""),this.slurp.match].join(""),"gm")}},{key:"truncate",value:function(t){return t&&t.replace(/^(?:\r\n|\r|\n)/,"")}},{key:"compile",value:function(t,e){var n=this,i=this.vars,r=i.SCOPE,o=i.SAFE,c=i.BUFFER,u=i.COMPONENT;this.rmWhitespace&&(t=t.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=t.replace(this.slurpStart,this.token.start).replace(this.slurpEnd,this.token.end);var s,h,a,f="".concat(c,"('");s=this.regex,h=function(e,i,r){f+=(""+t.slice(i,r)).replace(b,(function(t){return"\\"+d[t]})),e.forEach((function(t,e){t&&(f+=n.formats[e](t))}))},a=0,t.replace(s,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return h(t,a,e),a=e+n.length,n})),f="try{".concat(f+="');","}catch(e){console.info(e)}"),this.withObject&&(f="with(".concat(r,"){").concat(f,"}")),f="".concat(c,".start();").concat(f,"return ").concat(c,".end();"),f+="\n//# sourceURL=".concat(e);var l=null;try{(l=new Function(r,u,c,o,f)).source="(function(".concat(r,",").concat(u,",").concat(c,",").concat(o,"){\n").concat(f,"\n})")}catch(t){throw t.filename=e,t.source=f,t}return l}}]),t}(),N="undefined"!=typeof globalThis?globalThis:window||self,W=function(){function t(e){n(this,t),o(this,"list",{}),this.configure(e),!1===v()&&this.load(N[this.namespace])}return r(t,[{key:"configure",value:function(t){this.list={},this.namespace=t.export}},{key:"load",value:function(t){return E(this.list,t),this}},{key:"exist",value:function(t){return P(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,e){return this.list[t]=e,this}}]),t}(),q=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],D=" ",K='"',X="/",Y="<",J=">",V=function(t,e,n){var i=[],r=-1===q.indexOf(t),o=function(t,e,n){var i=[];return F(t,(function(t,n,r){var o=e(t,n,r);!1===l(o)&&i.push(o)})),i}(e,(function(t,e){if(null!=t)return[k(e),[K,k(t),K].join("")].join("=")})).join(D);return i.push([Y,t,D,o,J].join("")),n&&i.push(n instanceof Array?n.join(""):n),r&&i.push([Y,X,t,J].join("")),i.join("")},z=function(t){return Promise.all(t).then((function(t){return t.join("")}))},G=function(){function t(e){n(this,t),this.configure(e)}return r(t,[{key:"configure",value:function(t,e){var n=t.vars,i=n.EXTEND,r=n.LAYOUT,o=n.BLOCKS,c=n.BUFFER,u=n.MACRO,a=n.COMPONENT;function f(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),E(this,t)}this.create=function(t){return new f(t)},this.helpers=function(t){E(f.prototype,t)},f.prototype=E({},e||{}),f.define=f.method=function(t,e,n,i,r){return Object.defineProperty(f.prototype,t,{value:e,writable:n||!1,configurable:i||!1,enumerable:r||!1})},f.define(c,function(){var t=[],e=[];function n(t){e.push(t)}return n.start=function(){e=[]},n.backup=function(){t.push(e.concat()),e=[]},n.restore=function(){var n=e.concat();return e=t.pop(),z(n)},n.error=function(t){throw t},n.end=function(){return z(e)},n}()),f.define(o,{},!0),f.define(u,{},!0),f.define(r,!1,!0),f.define(i,!1,!0),f.method("initBlocks",(function(){this[o]={}})),f.method("initMacro",(function(){this[u]={}})),f.method("getMacro",(function(){return this[u]})),f.method("getBuffer",(function(){return this[c]})),f.method("getComponent",(function(){var t=this;return a in t?function(){return t[a].apply(t,arguments)}:function(){console.log("%s function not defined",a)}})),f.method("getBlocks",(function(){return this[o]})),f.method("setExtend",(function(t){this[i]=t})),f.method("getExtend",(function(){return this[i]})),f.method("setLayout",(function(t){this[r]=t})),f.method("getLayout",(function(){return this[r]})),f.method("clone",(function(t){var e=[r,i,c];return!0===t&&e.push(o),S(this,e)})),f.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),f.method("echo",(function(){var t=this.getBuffer();[].slice.call(arguments).forEach(t)})),f.method("fn",(function(t){var e=this.getBuffer(),n=this;return function(){return e.backup(),s(t)&&t.apply(n,arguments),e.restore()}})),f.method("get",(function(t,e){var n=x(this,t),i=n.shift(),r=n.pop();return P(i,r)?i[r]:e})),f.method("set",(function(t,e){var n=x(this,t),i=n.shift(),r=n.pop();return this.getExtend()&&P(i,r)?i[r]:i[r]=e})),f.method("macro",(function(t,e){var n=this.getMacro(),i=this.fn(e),r=this;n[t]=function(){return r.echo(i.apply(void 0,arguments))}})),f.method("call",(function(t){var e=this.getMacro()[t],n=[].slice.call(arguments,1);if(s(e))return e.apply(e,n)})),f.method("block",(function(t,e){var n=this,i=this.getBlocks();if(i[t]=i[t]||[],i[t].push(this.fn(e)),!this.getExtend()){var r=Object.assign([],i[t]),o=function(){return r.shift()};this.echo(o()(function t(){var e=o();return e?function(){n.echo(e(t()))}:O}()))}})),f.method("include",(function(t,e,n){var i=!1===n?{}:this.clone(!0),r=E(i,e||{}),o=this.render(t,r);this.echo(o)})),f.method("use",(function(t,e){var n=this.require(t);this.echo(B(n,(function(t){var n=this.getMacro();F(t,(function(t,i){n[[e,i].join(".")]=t}))}),this))})),f.method("async",(function(t,e){this.echo(B(t,(function(t){return this.fn(e)(t)}),this))})),f.method("node",(function(t,e,n){return V(t,e,n)})),f.method("el",(function(t,e,n){s(n)&&(n=this.fn(n)()),this.echo(B(n,(function(n){return V(t,e,n)}),this))})),f.method("each",(function(t,e){h(t)&&(t=this.get(t,[])),F(t,e)}))}}]),t}(),H=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,t),o(this,"export",["cache","render","require","helpers","configure","preload","compile","create","__express"]),this.config={},this.scope={},$(this.config,e),function(t,e){(arguments.length>2&&void 0!==arguments[2]?arguments[2]:[]).forEach((function(n){n in t&&(t[n]=t[n].bind(e))}))}(this,this,this.export),this.context=new G(this.config),this.compiler=new L(this.config),this.cache=new W(this.config),this.template=new A(this.config,this.cache,this.compiler),this.helpers({require:this.require,render:this.render})}return r(t,[{key:"configure",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return $(this.config,t),this.context.configure(this.config,this.scope),this.compiler.configure(this.config),this.cache.configure(this.config),this.template.configure(this.config),this.config}},{key:"output",value:function(t,e){return this.template.get(t).then((function(t){return t.call(e,e,e.getComponent(),e.getBuffer(),w)}))}},{key:"render",value:function(t,e){var n=this,i=j(t,this.config.extension),r=this.context.create(e);return this.output(i,r).then((function(t){if(r.getExtend()){r.setExtend(!1);var e=r.getLayout(),i=r.clone();return n.render(e,i)}return t}))}},{key:"require",value:function(t){var e=j(t,this.config.extension),n=this.context.create({});return this.output(e,n).then((function(){return n.getMacro()}))}},{key:"create",value:function(){return new t(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}},{key:"helpers",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.context.helpers(E(this.scope,t))}},{key:"preload",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.cache.load(t)}},{key:"compile",value:function(t,e){return this.compiler.compile(t,e)}},{key:"__express",value:function(t,e,n){s(e)&&(n=e,e={});var i=E({},(e=e||{}).settings),r=u(h,R.path,i.views),o=u(a,R.cache,i["view cache"]),c=E({},i["view options"]),f=T.relative(r,t);return c.path=r,c.cache=o,this.configure(c),this.render(f,e).then((function(t){n(null,t)})).catch((function(t){n(t)}))}}]),t}(),I=new H({}),Q=I.__express,Z=I.render,tt=I.context,et=I.compile,nt=I.helpers,it=I.preload,rt=I.configure,ot=I.create;t.EJS=H,t.__express=Q,t.compile=et,t.configure=rt,t.context=tt,t.create=ot,t.element=V,t.helpers=nt,t.preload=it,t.render=Z,t.safeValue=w}));
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "EJS Templates",
4
4
  "homepage": "https://github.com/kosatyi/ejs",
5
5
  "type": "module",
6
- "version": "0.0.56",
6
+ "version": "0.0.57",
7
7
  "main": "dist/cjs/index.js",
8
8
  "module": "dist/esm/index.js",
9
9
  "browser": "dist/umd/index.js",