@kosatyi/ejs 0.0.29 → 0.0.30

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
@@ -294,8 +294,8 @@ var Compiler = /*#__PURE__*/function () {
294
294
  _this.formats.push(item.format.bind(_this.vars));
295
295
  });
296
296
  this.regex = new RegExp(this.matches.join('|').concat('|$'), 'g');
297
- this.slurpStart = new RegExp([this.slurp.match, this.slurp.start].join(''), 'gm');
298
- this.slurpEnd = new RegExp([this.slurp.end, this.slurp.match].join(''), 'gm');
297
+ this.slurpStart = new RegExp([this.slurp.match, this.slurp.start.join('')].join(''), 'gm');
298
+ this.slurpEnd = new RegExp([this.slurp.end.join(''), this.slurp.match].join(''), 'gm');
299
299
  }
300
300
  }, {
301
301
  key: "compile",
@@ -306,7 +306,7 @@ var Compiler = /*#__PURE__*/function () {
306
306
  SAFE = _this$vars.SAFE,
307
307
  BUFFER = _this$vars.BUFFER;
308
308
  content = content.replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
309
- content = content.replace(this.slurpStart, this.slurp.start).replace(this.slurpEnd, this.slurp.end);
309
+ content = content.replace(this.slurpStart, this.token.start).replace(this.slurpEnd, this.token.end);
310
310
  var source = "".concat(BUFFER, "('");
311
311
  matchTokens(this.regex, content, function (params, index, offset) {
312
312
  source += symbols(content.slice(index, offset));
package/dist/ejs.js CHANGED
@@ -289,8 +289,8 @@
289
289
  _this.formats.push(item.format.bind(_this.vars));
290
290
  });
291
291
  this.regex = new RegExp(this.matches.join('|').concat('|$'), 'g');
292
- this.slurpStart = new RegExp([this.slurp.match, this.slurp.start].join(''), 'gm');
293
- this.slurpEnd = new RegExp([this.slurp.end, this.slurp.match].join(''), 'gm');
292
+ this.slurpStart = new RegExp([this.slurp.match, this.slurp.start.join('')].join(''), 'gm');
293
+ this.slurpEnd = new RegExp([this.slurp.end.join(''), this.slurp.match].join(''), 'gm');
294
294
  }
295
295
  }, {
296
296
  key: "compile",
@@ -301,7 +301,7 @@
301
301
  SAFE = _this$vars.SAFE,
302
302
  BUFFER = _this$vars.BUFFER;
303
303
  content = content.replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
304
- content = content.replace(this.slurpStart, this.slurp.start).replace(this.slurpEnd, this.slurp.end);
304
+ content = content.replace(this.slurpStart, this.token.start).replace(this.slurpEnd, this.token.end);
305
305
  var source = "".concat(BUFFER, "('");
306
306
  matchTokens(this.regex, content, function (params, index, offset) {
307
307
  source += symbols(content.slice(index, offset));
package/dist/ejs.min.js CHANGED
@@ -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";var e={},n={export:"ejs.precompiled",cache:!0,path:"views",resolver:null,extension:"ejs",withObject:!1,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),e=t.shift();return t.filter(e).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,e,n){return null==(n=t)?"":e?v(n):n},m=function(t,e){var n=t,r=e.split("."),i=r.pop();return r.forEach((function(t){n=n[t]=n[t]||{}})),[n,i]},g=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},y=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=e.shift();return e.filter((function(t){return t})).reduce((function(t,e){return Object.assign(t,e)}),r)},b=function(){},w=function(t,e){var n;for(n in t)k(t,n)&&e(t[n],n,t)},x=function(t,e){return function(t,e,n){var r=t instanceof Array,i=r?[]:{};return w(t,(function(t,n,o){var c=e(t,n,o);void 0!==c&&(r?i.push(c):i[n]=c)})),i}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},j=function(t,e,n){return Promise.resolve(t).then(e.bind(n))},k=function(t,e){return t&&t.hasOwnProperty(e)},E=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],O=" ",F='"',P="/",S="<",B=">",R=function(t,e,n){var r=[],i=-1===E.indexOf(t),o=function(t,e,n){var r=[];return w(t,(function(t,n,i){var o=e(t,n,i);void 0!==o&&r.push(o)})),r}(e,(function(t,e){if(null!=t)return[v(e),[F,v(t),F].join("")].join("=")})).join(O);return r.push([S,t,O,o,B].join("")),n&&r.push(n instanceof Array?n.join(""):n),i&&r.push([S,P,t,B].join("")),r.join("")};function $(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function T(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,A(r.key),r)}}function U(t,e,n){return e&&T(t.prototype,e),n&&T(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function A(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;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 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(e){$(this,t),this.configure(e)}return U(t,[{key:"configure",value:function(t){var e=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){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(""),"gm"),this.slurpEnd=new RegExp([this.slurp.end,this.slurp.match].join(""),"gm")}},{key:"compile",value:function(t,e){var n=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(e,r,i){h+=(""+t.slice(r,i)).replace(p,(function(t){return"\\"+a[t]})),e.forEach((function(t,e){t&&(h+=n.formats[e](t))}))},f=0,t.replace(u,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return s(t,f,e),f=e+n.length,n})),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(e);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=e,t.source=h,t}return l}}]),t}(),L=function(){function t(e){$(this,t),this.configure(e)}return U(t,[{key:"configure",value:function(t){this.namespace=t.export,this.useStrict=!1===t.withObject}},{key:"wrapper",value:function(t){var e="";return e+="(function(global,factory){",e+='typeof exports === "object" && typeof module !== "undefined" ?',e+="module.exports = factory():",e+='typeof define === "function" && define.amd ? define(factory):',e+='(global = typeof globalThis !== "undefined" ? globalThis:',e+='global || self,global["'+this.namespace+'"] = factory())',e+="})(this,(function(){",this.useStrict&&(e+="'use strict';\n"),e+="var list = {};\n",t.forEach((function(t){e+="list["+JSON.stringify(t.name)+"]="+String(t.content)+";\n"})),e+="return list;}));\n"}}]),t}(),C=function(t){return fetch(t).then((function(t){return t.text()}))},N=function(t){return new Promise((function(n,r){e.readFile(t,(function(t,e){t?r(t):n(e.toString())}))}))},q=function(){function t(e,n,r){$(this,t),this.cache=n,this.compiler=r,this.configure(e)}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,e){return(e=[t,e].join("/")).replace(/\/\//g,"/")}(this.path,t))}},{key:"result",value:function(t,e){return this.cache.set(e,t),t}},{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(e.compiler.compile(n,t),t)}));return this.result(n,t)}}]),t}(),D=function(t){return Promise.all(t).then((function(t){return t.join("")}))},K=function(){function t(e){$(this,t),this.configure(e)}return U(t,[{key:"configure",value:function(t,e){var n=t.vars,r=n.EXTEND,c=n.LAYOUT,u=n.BLOCKS,s=n.BUFFER,a=n.MACRO;function f(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),y(this,t)}this.create=function(t){return new f(t)},this.helpers=function(t){y(f.prototype,t)},f.prototype=y({},e||{}),f.defineProp=f.method=function(t,e){var n=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(f.prototype,t,{value:e,writable:n,configurable:r,enumerable:i})},f.defineProp(s,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(),D(n)},n.error=function(t){throw t},n.end=function(){return D(e)},n}()),f.defineProp(u,{},!0),f.defineProp(a,{},!0),f.defineProp(c,!1,!0),f.defineProp(r,!1,!0),f.method("initBlocks",(function(){this[u]={}})),f.method("initMacro",(function(){this[a]={}})),f.method("getMacro",(function(){return this[a]})),f.method("getBuffer",(function(){return this[s]})),f.method("getBlocks",(function(){return this[u]})),f.method("setExtend",(function(t){this[r]=t})),f.method("getExtend",(function(){return this[r]})),f.method("setLayout",(function(t){this[c]=t})),f.method("getLayout",(function(){return this[c]})),f.method("clone",(function(t){var e=[c,r,s];return!0===t&&e.push(u),x(this,e)})),f.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),f.method("echo",(function(){var t=this.getBuffer(),e=[].slice.call(arguments);e.forEach(t)})),f.method("fn",(function(t){var e=this.getBuffer(),n=this;return function(){return e.backup(),i(t)&&t.apply(n,arguments),e.restore()}})),f.method("get",(function(t,e){var n=m(this,t),r=n.shift(),i=n.pop();return k(r,i)?r[i]:e})),f.method("set",(function(t,e){var n=m(this,t),r=n.shift(),i=n.pop();return this.getExtend()&&k(r,i)?r[i]:r[i]=e})),f.method("macro",(function(t,e){var n=this.getMacro(),r=this.fn(e),i=this;n[t]=function(){return i.echo(r.apply(void 0,arguments))}})),f.method("call",(function(t){var e=this.getMacro(),n=e[t],r=[].slice.call(arguments,1);if(i(n))return n.apply(n,r)})),f.method("block",(function(t,e){var n=this,r=this.getBlocks();if(r[t]=r[t]||[],r[t].push(this.fn(e)),!this.getExtend()){var i=Object.assign([],r[t]),o=function(){return i.shift()};this.echo(o()(function t(){var e=o();return e?function(){n.echo(e(t()))}:b}()))}})),f.method("include",(function(t,e,n){var r=!1===n?{}:this.clone(!0),i=y(r,e||{}),o=this.render(t,i);this.echo(o)})),f.method("use",(function(t,e){var n=this.require(t);this.echo(j(n,(function(t){var n=this.getMacro();w(t,(function(t,r){n[[e,r].join(".")]=t}))}),this))})),f.method("async",(function(t,e){this.echo(j(t,(function(t){return this.fn(e)(t)}),this))})),f.method("node",(function(t,e,n){return R(t,e,n)})),f.method("el",(function(t,e,n){i(n)&&(n=this.fn(n)()),this.echo(j(n,(function(n){return R(t,e,n)}),this))})),f.method("each",(function(t,e){o(t)&&(t=this.get(t,[])),w(t,e)}))}}]),t}(),X="undefined"!=typeof globalThis?globalThis:window||self,Y=function(){function t(e){var n,r,i;$(this,t),n=this,i={},(r=A(r="list"))in n?Object.defineProperty(n,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[r]=i,this.configure(e),!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,e){return this.list[t]=e,this}}]),t}(),J=function(t,e){y(t,{export:r(o,n.export,t.export,e.export),path:r(o,n.path,t.path,e.path),resolver:r(i,n.resolver,t.resolver,e.resolver),extension:r(o,n.extension,t.extension,e.extension),withObject:r(c,n.withObject,t.withObject,e.withObject),token:y({},n.token,t.token,e.token),vars:y({},n.vars,t.vars,e.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),m=function(t){J(s,t),f.configure(s,a),h.configure(s),l.configure(s),p.configure(s),v.configure(s)},b=function(t,e){return v.get(t).then((function(t){return t.call(e,e,e.getBuffer(),d)}))},w=function(t,e){var n=g(t,s.extension),r=f.create(e);return b(n,r).then((function(t){if(r.getExtend()){r.setExtend(!1);var e=r.getLayout(),n=r.clone();return w(e,n)}return t}))},x=function(t){f.helpers(y(a,t||{}))};return x({require:function(t){return function(t){var e=g(t,s.extension),n=f.create({});return b(e,n).then((function(){return n.getMacro()}))}(t)},render:function(t,e){return w(t,e)}}),{render:w,helpers:x,configure:m,wrapper:function(t){return l.wrapper(t)},compile:function(t,e){return h.compile(t,e)},create:function(e){return t(e)},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,n.path,a.views),h=r(c,n.cache,a["view cache"]),l=y({},a["view options"]),p=e.relative(f,t);return l.path=f,l.cache=h,m(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})}));
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:!1,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},m=function(t,n){var e=t,r=n.split("."),i=r.pop();return r.forEach((function(t){e=e[t]=e[t]||{}})),[e,i]},g=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("")].join(""),"gm"),this.slurpEnd=new RegExp([this.slurp.end.join(""),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.token.start).replace(this.slurpEnd,this.token.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,n){var e=t.vars,r=e.EXTEND,c=e.LAYOUT,u=e.BLOCKS,s=e.BUFFER,a=e.MACRO;function f(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),y(this,t)}this.create=function(t){return new f(t)},this.helpers=function(t){y(f.prototype,t)},f.prototype=y({},n||{}),f.defineProp=f.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(f.prototype,t,{value:n,writable:e,configurable:r,enumerable:i})},f.defineProp(s,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}()),f.defineProp(u,{},!0),f.defineProp(a,{},!0),f.defineProp(c,!1,!0),f.defineProp(r,!1,!0),f.method("initBlocks",(function(){this[u]={}})),f.method("initMacro",(function(){this[a]={}})),f.method("getMacro",(function(){return this[a]})),f.method("getBuffer",(function(){return this[s]})),f.method("getBlocks",(function(){return this[u]})),f.method("setExtend",(function(t){this[r]=t})),f.method("getExtend",(function(){return this[r]})),f.method("setLayout",(function(t){this[c]=t})),f.method("getLayout",(function(){return this[c]})),f.method("clone",(function(t){var n=[c,r,s];return!0===t&&n.push(u),j(this,n)})),f.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),f.method("echo",(function(){var t=this.getBuffer(),n=[].slice.call(arguments);n.forEach(t)})),f.method("fn",(function(t){var n=this.getBuffer(),e=this;return function(){return n.backup(),i(t)&&t.apply(e,arguments),n.restore()}})),f.method("get",(function(t,n){var e=m(this,t),r=e.shift(),i=e.pop();return k(r,i)?r[i]:n})),f.method("set",(function(t,n){var e=m(this,t),r=e.shift(),i=e.pop();return this.getExtend()&&k(r,i)?r[i]:r[i]=n})),f.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))}})),f.method("call",(function(t){var n=this.getMacro(),e=n[t],r=[].slice.call(arguments,1);if(i(e))return e.apply(e,r)})),f.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}()))}})),f.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)})),f.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))})),f.method("async",(function(t,n){this.echo(x(t,(function(t){return this.fn(n)(t)}),this))})),f.method("node",(function(t,n,e){return R(t,n,e)})),f.method("el",(function(t,n,e){i(e)&&(e=this.fn(e)()),this.echo(x(e,(function(e){return R(t,n,e)}),this))})),f.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,t.export,n.export),path:r(o,e.path,t.path,n.path),resolver:r(i,e.resolver,t.resolver,n.resolver),extension:r(o,e.extension,t.extension,n.extension),withObject:r(c,e.withObject,t.withObject,n.withObject),token:y({},e.token,t.token,n.token),vars:y({},e.vars,t.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),m=function(t){J(s,t),f.configure(s,a),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=g(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=g(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:m,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,e.path,a.views),h=r(c,e.cache,a["view cache"]),l=y({},a["view options"]),p=n.relative(f,t);return l.path=f,l.cache=h,m(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
@@ -282,11 +282,11 @@ class Compiler {
282
282
  });
283
283
  this.regex = new RegExp(this.matches.join('|').concat('|$'), 'g');
284
284
  this.slurpStart = new RegExp(
285
- [this.slurp.match, this.slurp.start].join(''),
285
+ [this.slurp.match, this.slurp.start.join('')].join(''),
286
286
  'gm'
287
287
  );
288
288
  this.slurpEnd = new RegExp(
289
- [this.slurp.end, this.slurp.match].join(''),
289
+ [this.slurp.end.join(''), this.slurp.match].join(''),
290
290
  'gm'
291
291
  );
292
292
  }
@@ -294,8 +294,8 @@ class Compiler {
294
294
  const { SCOPE, SAFE, BUFFER } = this.vars;
295
295
  content = content.replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
296
296
  content = content
297
- .replace(this.slurpStart, this.slurp.start)
298
- .replace(this.slurpEnd, this.slurp.end);
297
+ .replace(this.slurpStart, this.token.start)
298
+ .replace(this.slurpEnd, this.token.end);
299
299
  let source = `${BUFFER}('`;
300
300
  matchTokens(this.regex, content, (params, index, offset) => {
301
301
  source += symbols(content.slice(index, offset));
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.29",
5
+ "version": "0.0.30",
6
6
  "main": "dist/ejs.cjs",
7
7
  "module": "dist/ejs.mjs",
8
8
  "browser": "dist/ejs.js",
@@ -26,9 +26,7 @@
26
26
  "devDependencies": {
27
27
  "@kosatyi/rollup": "^0.0.1",
28
28
  "@babel/core": "^7.20.12",
29
- "@babel/preset-env": "^7.20.2",
30
- "glob": "^10.2.7",
31
- "terser": "^5.16.1"
29
+ "@babel/preset-env": "^7.20.2"
32
30
  },
33
31
  "directories": {
34
32
  "test": "test"