@kosatyi/ejs 0.0.40 → 0.0.41
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 +2 -0
- package/dist/ejs.js +2 -0
- package/dist/ejs.min.js +1 -1
- package/dist/ejs.mjs +2 -1
- package/package.json +1 -1
package/dist/ejs.cjs
CHANGED
|
@@ -847,6 +847,7 @@ var _init = init({}),
|
|
|
847
847
|
helpers = _init.helpers,
|
|
848
848
|
configure = _init.configure,
|
|
849
849
|
compile = _init.compile,
|
|
850
|
+
context = _init.context,
|
|
850
851
|
create = _init.create,
|
|
851
852
|
preload = _init.preload,
|
|
852
853
|
__express = _init.__express;
|
|
@@ -854,6 +855,7 @@ var _init = init({}),
|
|
|
854
855
|
exports.__express = __express;
|
|
855
856
|
exports.compile = compile;
|
|
856
857
|
exports.configure = configure;
|
|
858
|
+
exports.context = context;
|
|
857
859
|
exports.create = create;
|
|
858
860
|
exports.element = element;
|
|
859
861
|
exports.helpers = helpers;
|
package/dist/ejs.js
CHANGED
|
@@ -841,6 +841,7 @@
|
|
|
841
841
|
helpers = _init.helpers,
|
|
842
842
|
configure = _init.configure,
|
|
843
843
|
compile = _init.compile,
|
|
844
|
+
context = _init.context,
|
|
844
845
|
create = _init.create,
|
|
845
846
|
preload = _init.preload,
|
|
846
847
|
__express = _init.__express;
|
|
@@ -848,6 +849,7 @@
|
|
|
848
849
|
exports.__express = __express;
|
|
849
850
|
exports.compile = compile;
|
|
850
851
|
exports.configure = configure;
|
|
852
|
+
exports.context = context;
|
|
851
853
|
exports.create = create;
|
|
852
854
|
exports.element = element;
|
|
853
855
|
exports.helpers = helpers;
|
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:"ejsPrecompiled",watch:!1,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]+?)"}},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=function(t){return void 0===t},s="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),a=function(){return s},h={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},f={"&":"&","<":"<",">":">",'"':""","'":"'"},l=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},p=l(f),v=l(h),d=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(""+t).replace(p,(function(t){return f[t]}))},m=function(t,e,n){return null==(n=t)?"":e?d(n):n},g=function(t,e){var n=t,r=e.split("."),i=r.pop();return r.forEach((function(t){n=n[t]=n[t]||{}})),[n,i]},y=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},b=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)},w=function(){},j=function(t,e){var n;for(n in t)E(t,n)&&e(t[n],n,t)},k=function(t,e){return function(t,e,n){var r=t instanceof Array,i=r?[]:{};return j(t,(function(t,n,o){var c=e(t,n,o);!1===u(c)&&(r?i.push(c):i[n]=c)})),i}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},x=function(t,e,n){return Promise.resolve(t).then(e.bind(n))},E=function(t,e){return t&&t.hasOwnProperty(e)},O=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],F=" ",B='"',P="/",R="<",S=">",$=function(t,e,n){var r=[],i=-1===O.indexOf(t),o=function(t,e,n){var r=[];return j(t,(function(t,n,i){var o=e(t,n,i);!1===u(o)&&r.push(o)})),r}(e,(function(t,e){if(null!=t)return[d(e),[B,d(t),B].join("")].join("=")})).join(F);return r.push([R,t,F,o,S].join("")),n&&r.push(n instanceof Array?n.join(""):n),i&&r.push([R,P,t,S].join("")),r.join("")};function M(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,U(r.key),r)}}function C(t,e,n){return e&&T(t.prototype,e),n&&T(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function U(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 A=[{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){M(this,t),this.configure(e)}return C(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]},A.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,r=this.vars,i=r.SCOPE,o=r.SAFE,c=r.BUFFER,u=r.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,a,f,l="".concat(c,"('");s=this.regex,a=function(e,r,i){l+=(""+t.slice(r,i)).replace(v,(function(t){return"\\"+h[t]})),e.forEach((function(t,e){t&&(l+=n.formats[e](t))}))},f=0,t.replace(s,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return a(t,f,e),f=e+n.length,n})),l="try{".concat(l+="');","}catch(e){console.info(e)}"),this.withObject&&(l="with(".concat(i,"){").concat(l,"}")),l="".concat(c,".start();").concat(l,"return ").concat(c,".end();"),l+="\n//# sourceURL=".concat(e);var p=null;try{(p=new Function(i,u,c,o,l)).source="(function(".concat(i,",").concat(u,",").concat(c,",").concat(o,"){\n").concat(l,"\n})")}catch(t){throw t.filename=e,t.source=l,t}return p}}]),t}(),L=function(t,e){return e=(e=[t,e].join("/")).replace(/\/\//g,"/")},N=function(t,e){return fetch(L(t,e)).then((function(t){return t.text()}))},W=function(t,n){return new Promise((function(r,i){e.readFile(L(t,n),(function(t,e){t?i(t):r(e.toString())}))}))},q=function(){function t(e,n,r){M(this,t),this.cache=n,this.watcher=null,this.compiler=r,this.configure(e)}return C(t,[{key:"configure",value:function(t){var n,r,o;this.path=t.path,this.resolver=i(t.resolver)?t.resolver:a()?W:N,(n=this.watcher)&&n.unwatch("."),t.watch&&a()&&(this.watcher=(r=this.path,o=this.cache,e.watch(".",{cwd:r}).on("change",(function(t){o.remove(t)})).on("error",(function(t){console.log("watcher error: "+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 i(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}(),D=function(t){return Promise.all(t).then((function(t){return t.join("")}))},K=function(){function t(e){M(this,t),this.configure(e)}return C(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,h=n.COMPONENT;function f(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),b(this,t)}this.create=function(t){return new f(t)},this.helpers=function(t){b(f.prototype,t)},f.prototype=b({},e||{}),f.define=f.method=function(t,e,n,r,i){return Object.defineProperty(f.prototype,t,{value:e,writable:n||!1,configurable:r||!1,enumerable:i||!1})},f.define(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.define(u,{},!0),f.define(a,{},!0),f.define(c,!1,!0),f.define(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("getComponent",(function(){var t=this;return h in t?function(){return t[h].apply(t,arguments)}:function(){console.log("%s function not defined",h)}})),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),k(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=g(this,t),r=n.shift(),i=n.pop();return E(r,i)?r[i]:e})),f.method("set",(function(t,e){var n=g(this,t),r=n.shift(),i=n.pop();return this.getExtend()&&E(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()))}:w}()))}})),f.method("include",(function(t,e,n){var r=!1===n?{}:this.clone(!0),i=b(r,e||{}),o=this.render(t,i);this.echo(o)})),f.method("use",(function(t,e){var n=this.require(t);this.echo(x(n,(function(t){var n=this.getMacro();j(t,(function(t,r){n[[e,r].join(".")]=t}))}),this))})),f.method("async",(function(t,e){this.echo(x(t,(function(t){return this.fn(e)(t)}),this))})),f.method("node",(function(t,e,n){return $(t,e,n)})),f.method("el",(function(t,e,n){i(n)&&(n=this.fn(n)()),this.echo(x(n,(function(n){return $(t,e,n)}),this))})),f.method("each",(function(t,e){o(t)&&(t=this.get(t,[])),j(t,e)}))}}]),t}(),X="undefined"!=typeof globalThis?globalThis:window||self,Y=function(){function t(e){var n,r,i;M(this,t),n=this,i={},(r=U(r="list"))in n?Object.defineProperty(n,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[r]=i,this.configure(e),!1===a()&&this.load(X[this.namespace])}return C(t,[{key:"configure",value:function(t){this.list={},this.namespace=t.export}},{key:"load",value:function(t){return b(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,e){return this.list[t]=e,this}}]),t}(),V=function(t,e){b(t,{path:r(o,n.path,t.path,e.path),export:r(o,n.export,t.export,e.export),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),rmWhitespace:r(c,n.rmWhitespace,t.rmWhitespace,e.rmWhitespace),watch:r(c,n.watch,t.watch,e.watch),token:b({},n.token,t.token,e.token),vars:b({},n.vars,t.vars,e.vars)})},z=function t(u){var s={},a={};V(s,u||{});var h=new K(s),f=new _(s),l=new Y(s),p=new q(s,l,f),v=function(t){return V(s,t),h.configure(s,a),f.configure(s),l.configure(s),p.configure(s),s},d=function(t,e){return p.get(t).then((function(t){return t.call(e,e,e.getComponent(),e.getBuffer(),m)}))},g=function(t,e){var n=y(t,s.extension),r=h.create(e);return d(n,r).then((function(t){if(r.getExtend()){r.setExtend(!1);var e=r.getLayout(),n=r.clone();return g(e,n)}return t}))},w=function(t){h.helpers(b(a,t||{}))};return w({require:function(t){return function(t){var e=y(t,s.extension),n=h.create({});return d(e,n).then((function(){return n.getMacro()}))}(t)},render:function(t,e){return g(t,e)}}),{render:g,helpers:w,configure:v,compile:function(t,e){return f.compile(t,e)},create:function(e){return t(e)},preload:function(t){return l.load(t)},__express:function(t,u,s){i(u)&&(s=u,u={});var a=b({},(u=u||{}).settings),h=r(o,n.path,a.views),f=r(c,n.cache,a["view cache"]),l=b({},a["view options"]),p=e.relative(h,t);return l.path=h,l.cache=f,v(l),g(p,u).then((function(t){s(null,t)})).catch((function(t){s(t)}))}}}({}),G=z.render,H=z.helpers,I=z.configure,J=z.compile,Q=z.create,Z=z.preload,tt=z.__express;t.__express=tt,t.compile=J,t.configure=I,t.create=Q,t.element=$,t.helpers=H,t.preload=Z,t.render=G,t.safeValue=m,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
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:"ejsPrecompiled",watch:!1,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]+?)"}},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=function(t){return void 0===t},s="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),a=function(){return s},h={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},f={"&":"&","<":"<",">":">",'"':""","'":"'"},l=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},p=l(f),v=l(h),d=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(""+t).replace(p,(function(t){return f[t]}))},m=function(t,e,n){return null==(n=t)?"":e?d(n):n},g=function(t,e){var n=t,r=e.split("."),i=r.pop();return r.forEach((function(t){n=n[t]=n[t]||{}})),[n,i]},y=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},b=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)},w=function(){},j=function(t,e){var n;for(n in t)E(t,n)&&e(t[n],n,t)},x=function(t,e){return function(t,e,n){var r=t instanceof Array,i=r?[]:{};return j(t,(function(t,n,o){var c=e(t,n,o);!1===u(c)&&(r?i.push(c):i[n]=c)})),i}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},k=function(t,e,n){return Promise.resolve(t).then(e.bind(n))},E=function(t,e){return t&&t.hasOwnProperty(e)},O=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],F=" ",B='"',P="/",R="<",S=">",$=function(t,e,n){var r=[],i=-1===O.indexOf(t),o=function(t,e,n){var r=[];return j(t,(function(t,n,i){var o=e(t,n,i);!1===u(o)&&r.push(o)})),r}(e,(function(t,e){if(null!=t)return[d(e),[B,d(t),B].join("")].join("=")})).join(F);return r.push([R,t,F,o,S].join("")),n&&r.push(n instanceof Array?n.join(""):n),i&&r.push([R,P,t,S].join("")),r.join("")};function M(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,U(r.key),r)}}function C(t,e,n){return e&&T(t.prototype,e),n&&T(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function U(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 A=[{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){M(this,t),this.configure(e)}return C(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]},A.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,r=this.vars,i=r.SCOPE,o=r.SAFE,c=r.BUFFER,u=r.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,a,f,l="".concat(c,"('");s=this.regex,a=function(e,r,i){l+=(""+t.slice(r,i)).replace(v,(function(t){return"\\"+h[t]})),e.forEach((function(t,e){t&&(l+=n.formats[e](t))}))},f=0,t.replace(s,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return a(t,f,e),f=e+n.length,n})),l="try{".concat(l+="');","}catch(e){console.info(e)}"),this.withObject&&(l="with(".concat(i,"){").concat(l,"}")),l="".concat(c,".start();").concat(l,"return ").concat(c,".end();"),l+="\n//# sourceURL=".concat(e);var p=null;try{(p=new Function(i,u,c,o,l)).source="(function(".concat(i,",").concat(u,",").concat(c,",").concat(o,"){\n").concat(l,"\n})")}catch(t){throw t.filename=e,t.source=l,t}return p}}]),t}(),L=function(t,e){return e=(e=[t,e].join("/")).replace(/\/\//g,"/")},N=function(t,e){return fetch(L(t,e)).then((function(t){return t.text()}))},W=function(t,n){return new Promise((function(r,i){e.readFile(L(t,n),(function(t,e){t?i(t):r(e.toString())}))}))},q=function(){function t(e,n,r){M(this,t),this.cache=n,this.watcher=null,this.compiler=r,this.configure(e)}return C(t,[{key:"configure",value:function(t){var n,r,o;this.path=t.path,this.resolver=i(t.resolver)?t.resolver:a()?W:N,(n=this.watcher)&&n.unwatch("."),t.watch&&a()&&(this.watcher=(r=this.path,o=this.cache,e.watch(".",{cwd:r}).on("change",(function(t){o.remove(t)})).on("error",(function(t){console.log("watcher error: "+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 i(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}(),D=function(t){return Promise.all(t).then((function(t){return t.join("")}))},K=function(){function t(e){M(this,t),this.configure(e)}return C(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,h=n.COMPONENT;function f(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),b(this,t)}this.create=function(t){return new f(t)},this.helpers=function(t){b(f.prototype,t)},f.prototype=b({},e||{}),f.define=f.method=function(t,e,n,r,i){return Object.defineProperty(f.prototype,t,{value:e,writable:n||!1,configurable:r||!1,enumerable:i||!1})},f.define(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.define(u,{},!0),f.define(a,{},!0),f.define(c,!1,!0),f.define(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("getComponent",(function(){var t=this;return h in t?function(){return t[h].apply(t,arguments)}:function(){console.log("%s function not defined",h)}})),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=g(this,t),r=n.shift(),i=n.pop();return E(r,i)?r[i]:e})),f.method("set",(function(t,e){var n=g(this,t),r=n.shift(),i=n.pop();return this.getExtend()&&E(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()))}:w}()))}})),f.method("include",(function(t,e,n){var r=!1===n?{}:this.clone(!0),i=b(r,e||{}),o=this.render(t,i);this.echo(o)})),f.method("use",(function(t,e){var n=this.require(t);this.echo(k(n,(function(t){var n=this.getMacro();j(t,(function(t,r){n[[e,r].join(".")]=t}))}),this))})),f.method("async",(function(t,e){this.echo(k(t,(function(t){return this.fn(e)(t)}),this))})),f.method("node",(function(t,e,n){return $(t,e,n)})),f.method("el",(function(t,e,n){i(n)&&(n=this.fn(n)()),this.echo(k(n,(function(n){return $(t,e,n)}),this))})),f.method("each",(function(t,e){o(t)&&(t=this.get(t,[])),j(t,e)}))}}]),t}(),X="undefined"!=typeof globalThis?globalThis:window||self,Y=function(){function t(e){var n,r,i;M(this,t),n=this,i={},(r=U(r="list"))in n?Object.defineProperty(n,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[r]=i,this.configure(e),!1===a()&&this.load(X[this.namespace])}return C(t,[{key:"configure",value:function(t){this.list={},this.namespace=t.export}},{key:"load",value:function(t){return b(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,e){return this.list[t]=e,this}}]),t}(),V=function(t,e){b(t,{path:r(o,n.path,t.path,e.path),export:r(o,n.export,t.export,e.export),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),rmWhitespace:r(c,n.rmWhitespace,t.rmWhitespace,e.rmWhitespace),watch:r(c,n.watch,t.watch,e.watch),token:b({},n.token,t.token,e.token),vars:b({},n.vars,t.vars,e.vars)})},z=function t(u){var s={},a={};V(s,u||{});var h=new K(s),f=new _(s),l=new Y(s),p=new q(s,l,f),v=function(t){return V(s,t),h.configure(s,a),f.configure(s),l.configure(s),p.configure(s),s},d=function(t,e){return p.get(t).then((function(t){return t.call(e,e,e.getComponent(),e.getBuffer(),m)}))},g=function(t,e){var n=y(t,s.extension),r=h.create(e);return d(n,r).then((function(t){if(r.getExtend()){r.setExtend(!1);var e=r.getLayout(),n=r.clone();return g(e,n)}return t}))},w=function(t){h.helpers(b(a,t||{}))};return w({require:function(t){return function(t){var e=y(t,s.extension),n=h.create({});return d(e,n).then((function(){return n.getMacro()}))}(t)},render:function(t,e){return g(t,e)}}),{render:g,helpers:w,configure:v,compile:function(t,e){return f.compile(t,e)},create:function(e){return t(e)},preload:function(t){return l.load(t)},__express:function(t,u,s){i(u)&&(s=u,u={});var a=b({},(u=u||{}).settings),h=r(o,n.path,a.views),f=r(c,n.cache,a["view cache"]),l=b({},a["view options"]),p=e.relative(h,t);return l.path=h,l.cache=f,v(l),g(p,u).then((function(t){s(null,t)})).catch((function(t){s(t)}))}}}({}),G=z.render,H=z.helpers,I=z.configure,J=z.compile,Q=z.context,Z=z.create,tt=z.preload,et=z.__express;t.__express=et,t.compile=J,t.configure=I,t.context=Q,t.create=Z,t.element=$,t.helpers=H,t.preload=tt,t.render=G,t.safeValue=m,Object.defineProperty(t,"__esModule",{value:!0})}));
|
package/dist/ejs.mjs
CHANGED
|
@@ -900,9 +900,10 @@ const {
|
|
|
900
900
|
helpers,
|
|
901
901
|
configure,
|
|
902
902
|
compile,
|
|
903
|
+
context,
|
|
903
904
|
create,
|
|
904
905
|
preload,
|
|
905
906
|
__express,
|
|
906
907
|
} = init({});
|
|
907
908
|
|
|
908
|
-
export { __express, compile, configure, create, element, helpers, preload, render, safeValue };
|
|
909
|
+
export { __express, compile, configure, context, create, element, helpers, preload, render, safeValue };
|