@kosatyi/ejs 0.0.63 → 0.0.64
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 +16 -35
- package/dist/esm/index.js +16 -39
- package/dist/umd/index.js +687 -706
- package/dist/umd/index.min.js +1 -1
- package/package.json +1 -1
package/dist/umd/index.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";function n(t){return n="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},n(t)}var e=function(){var t=[].slice.call(arguments),n=t.shift();return t.filter(n).pop()},r=function(t){return"function"==typeof t},o=function(t){return"string"==typeof t},i=function(t){return"boolean"==typeof t},c=function(t){return"object"===n(t)},u=function(t){return void 0===t},s="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),f=function(){return s},a={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},h={"&":"&","<":"<",">":">",'"':""","'":"'"},l=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},p=l(h),d=l(a),m=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(p,(function(t){return h[t]}))},v=function(t){return(""+t).replace(d,(function(t){return"\\"+a[t]}))},g=function(t,n){var e=t;return null==e?"":!0===n?m(e):e},w=function(t,n){return t instanceof n},y=function(t,n,e){for(var o=t,i=String(n).split("."),c=i.pop(),u=0;u<i.length;u++){var s=i[u];if(r(o.toJSON)&&(o=o.toJSON()),e&&!1===o.hasOwnProperty(s)){o={};break}o=o[s]=o[s]||{}}return r(o.toJSON)&&(o=o.toJSON()),[o,c]},b=function(t,n){var e=t.split(".").pop();return e!==n&&(t=[t,n].join(".")),t},x=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)},j=function(){},E=function(t,n){var e;for(e in t)F(t,e)&&n(t[e],e,t)},O=function(t,n){return function(t,n,e){var r=t instanceof Array,o=r?[]:{};return E(t,(function(t,e,i){var c=n(t,e,i);!1===u(c)&&(r?o.push(c):o[e]=c)})),o}(t,(function(t,e){if(-1===n.indexOf(e))return t}))},k=function(t,n,e){return Promise.resolve(t).then(n.bind(e))},F=function(t,n){return t&&t.hasOwnProperty(n)},S={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]+?)"}},B={},R=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],$=" ",P='"',N="/",U="<",A=">",C=function(t,n,e){var r=[],o=-1===R.indexOf(t),i=function(t,n,e){var r=[];return E(t,(function(t,e,o){var i=n(t,e,o);!1===u(i)&&r.push(i)})),r}(n,(function(t,n){if(null!=t)return[m(n),[P,m(t),P].join("")].join("=")})).join($);return r.push([U,t,$,i,A].join("")),e&&r.push(e instanceof Array?e.join(""):e),o&&r.push([U,N,t,A].join("")),r.join("")},T=function(t,n){x(t,{path:e(o,S.path,t.path,n.path),export:e(o,S.export,t.export,n.export),resolver:e(r,S.resolver,t.resolver,n.resolver),extension:e(o,S.extension,t.extension,n.extension),withObject:e(i,S.withObject,t.withObject,n.withObject),rmWhitespace:e(i,S.rmWhitespace,t.rmWhitespace,n.rmWhitespace),watch:e(i,S.watch,t.watch,n.watch),chokidar:e(c,S.export,t.export,n.export),token:x({},S.token,t.token,n.token),vars:x({},S.vars,t.vars,n.vars)})},M=function(t,n){return n=(n=[t,n].join("/")).replace(/\/\//g,"/")},L=function(t,n){return fetch(M(t,n)).then((function(t){return t.text()}))},W=function(t,n){return new Promise((function(e,r){B.readFile(M(t,n),(function(t,n){t?r(t):e(n.toString())}))}))},J=function(t){return r(t)?t:f()?W:L};function _(t,n,e){if(!1===w(this,_))return new _(t,n,e);var o={},i=function(t,e){return n.set(t,e),e},c=function(t){return o.resolver(o.path,t)};this.configure=function(t){o.path=t.path,o.chokidar=t.chokidar,o.resolver=J(t.resolver),o.watcher=function(t){if(o.watcher&&o.watcher.unwatch("."),t.watch&&t.chokidar&&f())return t.chokidar.watch(".",{cwd:o.path}).on("change",(function(t){n.remove(t)}))}(t)},this.get=function(t){return n.exist(t)?n.resolve(t):i(t,c(t).then((function(n){return i(t,function(t,n){return r(t)?t:e.compile(t,n)}(n,t))})))},this.configure(t)}var q=[{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 D(t){if(!1===w(this,D))return new D(t);var n={};this.configure=function(t){n.withObject=t.withObject,n.rmWhitespace=t.rmWhitespace,n.token=t.token,n.vars=t.vars,n.matches=[],n.formats=[],n.slurp={match:"[ \\t]*",start:[n.token.start,"_"],end:["_",n.token.end]},q.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))})),n.regex=new RegExp(n.matches.join("|").concat("|$"),"g"),n.slurpStart=new RegExp([n.slurp.match,n.slurp.start.join("")].join(""),"gm"),n.slurpEnd=new RegExp([n.slurp.end.join(""),n.slurp.match].join(""),"gm")},this.compile=function(t,e){var r=n.vars,o=r.SCOPE,i=r.SAFE,c=r.BUFFER,u=r.COMPONENT;n.rmWhitespace&&(t=t.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=t.replace(n.slurpStart,n.token.start).replace(n.slurpEnd,n.token.end);var s,f,a,h="".concat(c,"('");s=n.regex,f=function(e,r,o){h+=v(t.slice(r,o)),e.forEach((function(t,e){t&&(h+=n.formats[e](t))}))},a=0,t.replace(s,(function(){var t=[].slice.call(arguments,0,-1),n=t.pop(),e=t.shift();return f(t,a,n),a=n+e.length,e})),h="try{".concat(h+="');","}catch(e){console.info(e)}"),n.withObject&&(h="with(".concat(o,"){").concat(h,"}")),h="".concat(c,".start();").concat(h,"return ").concat(c,".end();"),h+="\n//# sourceURL=".concat(e);var l=null;try{(l=new Function(o,u,c,i,h)).source="(function(".concat(o,",").concat(u,",").concat(c,",").concat(i,"){\n").concat(h,"\n})")}catch(t){throw t.filename=e,t.source=h,t}return l},this.configure(t)}var K="undefined"!=typeof globalThis?globalThis:window||self;function X(t){if(!1===w(this,X))return new X;var n={list:{}};this.configure=function(t){n.list={},!1===f()&&this.load(K[t.export])},this.load=function(t){return x(n.list,t||{}),this},this.get=function(t){return n.list[t]},this.set=function(t,e){return n.list[t]=e,this},this.resolve=function(t){return Promise.resolve(this.get(t))},this.remove=function(t){delete n.list[t]},this.exist=function(t){return F(n.list,t)}}function Y(t){return Promise.all(t||[]).then((function(t){return t.join("")}))}var V=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(),Y(e)},e.error=function(t){throw t},e.end=function(){return Y(n)},e};function z(t){if(!1===w(this,z))return new z(t);this.configure=function(t,n){var e=t.vars,i=e.BLOCKS,c=e.MACRO,u=e.EXTEND,s=e.LAYOUT,f=e.BUFFER,a=e.COMPONENT;function h(t){this[i]={},this[c]={},x(this,t||{})}this.create=function(t){return new h(t)},this.helpers=function(t){x(h.prototype,t||{})},h.prototype=x({},n||{}),h.method=h.define=function(t,n,e,r,o){Object.defineProperty(h.prototype,t,{value:n,writable:e||!1,configurable:r||!1,enumerable:o||!1})},h.define(f,V()),h.define(i,{},!0),h.define(c,{},!0),h.define(s,!1,!0),h.define(u,!1,!0),h.method("getMacro",(function(){return this[c]})),h.method("getBuffer",(function(){return this[f]})),h.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)}})),h.method("getBlocks",(function(){return this[i]})),h.method("setExtend",(function(t){this[u]=t})),h.method("getExtend",(function(){return this[u]})),h.method("setLayout",(function(t){this[s]=t})),h.method("getLayout",(function(){return this[s]})),h.method("clone",(function(t){var n=[s,u,f];return!0===t&&n.push(i),O(this,n)})),h.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),h.method("echo",(function(){var t=this.getBuffer();[].slice.call(arguments).forEach(t)})),h.method("fn",(function(t){var n=this.getBuffer(),e=this;return function(){return n.backup(),r(t)&&t.apply(e,arguments),n.restore()}})),h.method("get",(function(t,n){var e=y(this,t,!0),r=e.shift(),o=e.pop();return F(r,o)?r[o]:n})),h.method("set",(function(t,n){var e=y(this,t,!1),r=e.shift(),o=e.pop();return this.getExtend()&&F(r,o)?r[o]:r[o]=n})),h.method("macro",(function(t,n){var e=this.getMacro(),r=this.fn(n),o=this;e[t]=function(){return o.echo(r.apply(void 0,arguments))}})),h.method("call",(function(t){var n=this.getMacro()[t],e=[].slice.call(arguments,1);if(r(n))return n.apply(n,e)})),h.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 o=Object.assign([],r[t]),i=function(){return o.shift()};this.echo(i()(function t(){var n=i();return n?function(){e.echo(n(t()))}:j}()))}})),h.method("include",(function(t,n,e){var r=!1===e?{}:this.clone(!0),o=x(r,n||{}),i=this.render(t,o);this.echo(i)})),h.method("use",(function(t,n){var e=this.require(t);this.echo(k(e,(function(t){var e=this.getMacro();E(t,(function(t,r){e[[n,r].join(".")]=t}))}),this))})),h.method("async",(function(t,n){this.echo(k(t,(function(t){return this.fn(n)(t)}),this))})),h.method("node",(function(t,n,e){return C(t,n,e)})),h.method("el",(function(t,n,e){r(e)&&(e=this.fn(e)()),this.echo(k(e,(function(e){return C(t,n,e)}),this))})),h.method("each",(function(t,n){o(t)&&(t=this.get(t,[])),E(t,n)}))},this.configure(t)}function G(t){if(!1===w(this,G))return new G(t);var n={},e={};T(e,t||{});var r=new z(e),o=new D(e),i=new X,c=new _(e,i,o),u=function(t,n){return c.get(t).then((function(t){return t.call(n,n,n.getComponent(),n.getBuffer(),g)}))},s=function t(n,o){var i=b(n,e.extension),c=r.create(o);return u(i,c).then((function(n){if(c.getExtend()){c.setExtend(!1);var e=c.getLayout(),r=c.clone();return t(e,r)}return n}))};this.configure=function(t){return T(e,t=t||{}),r.configure(e,n),o.configure(e),i.configure(e),c.configure(e),e},this.render=function(t,n){return s(t,n)},this.helpers=function(t){r.helpers(Object.assign(n,t||{}))},this.preload=function(t){return i.load(t||{})},this.create=function(t){return new G(t)},this.compile=function(t,n){return o.compile(t,n)},this.context=function(t){return r.create(t)},this.helpers({require:function(t){var n=b(t,e.extension),o=r.create({});return u(n,o).then((function(){return o.getMacro()}))},render:s})}var H=new G,I=H.render,Q=H.context,Z=H.compile,tt=H.helpers,nt=H.preload,et=H.configure,rt=H.create;t.EJS=G,t.__express=function(t,n,c){r(n)&&(c=n,n={});var u=x({},(n=n||{}).settings),s=e(o,S.path,u.views),f=e(i,S.cache,u["view cache"]),a=x({},u["view options"]),h=B.relative(s,t);return a.path=s,a.cache=f,configure(a),this.render(h,n).then((function(t){c(null,t)})).catch((function(t){c(t)}))},t.compile=Z,t.configure=et,t.context=Q,t.create=rt,t.element=C,t.helpers=tt,t.preload=nt,t.render=I,t.safeValue=g}));
|
|
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=function(){var t=[].slice.call(arguments),n=t.shift();return t.filter(n).pop()},r=function(t){return"function"==typeof t},o=function(t){return"string"==typeof t},i=function(t){return"boolean"==typeof t},c=function(t){return void 0===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={"&":"&","<":"<",">":">",'"':""","'":"'"},h=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},l=h(f),p=h(a),d=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(l,(function(t){return f[t]}))},m=function(t){return(""+t).replace(p,(function(t){return"\\"+a[t]}))},v=function(t,n){var e=t;return null==e?"":!0===n?d(e):e},g=function(t,n){return t instanceof n},b=function(t,n,e){for(var o=t,i=String(n).split("."),c=i.pop(),u=0;u<i.length;u++){var s=i[u];if(r(o.toJSON)&&(o=o.toJSON()),e&&!1===o.hasOwnProperty(s)){o={};break}o=o[s]=o[s]||{}}return r(o.toJSON)&&(o=o.toJSON()),[o,c]},w=function(t,n){var e=t.split(".").pop();return e!==n&&(t=[t,n].join(".")),t},x=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)},E=function(){},j=function(t,n){var e;for(e in t)k(t,e)&&n(t[e],e,t)},y=function(t,n){return function(t,n,e){var r=t instanceof Array,o=r?[]:{};return j(t,(function(t,e,i){var u=n(t,e,i);!1===c(u)&&(r?o.push(u):o[e]=u)})),o}(t,(function(t,e){if(-1===n.indexOf(e))return t}))},O=function(t,n,e){return Promise.resolve(t).then(n.bind(e))},k=function(t,n){return t&&t.hasOwnProperty(n)},F={export:"ejsPrecompiled",cache:!0,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]+?)"}},S=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],B=" ",R='"',$="/",P="<",N=">",U=function(t,n,e){var r=[],o=-1===S.indexOf(t),i=function(t,n,e){var r=[];return j(t,(function(t,e,o){var i=n(t,e,o);!1===c(i)&&r.push(i)})),r}(n,(function(t,n){if(null!=t)return[d(n),[R,d(t),R].join("")].join("=")})).join(B);return r.push([P,t,B,i,N].join("")),e&&r.push(e instanceof Array?e.join(""):e),o&&r.push([P,$,t,N].join("")),r.join("")},A=function(t,n){x(t,{path:e(o,F.path,t.path,n.path),export:e(o,F.export,t.export,n.export),resolver:e(r,F.resolver,t.resolver,n.resolver),extension:e(o,F.extension,t.extension,n.extension),withObject:e(i,F.withObject,t.withObject,n.withObject),rmWhitespace:e(i,F.rmWhitespace,t.rmWhitespace,n.rmWhitespace),cache:e(i,F.watch,t.watch,n.watch),token:x({},F.token,t.token,n.token),vars:x({},F.vars,t.vars,n.vars)})},C=function(t,n){return n=(n=[t,n].join("/")).replace(/\/\//g,"/")},T=function(t,n){return fetch(C(t,n)).then((function(t){return t.text()}))},M=function(t,e){return new Promise((function(r,o){n.readFile(C(t,e),(function(t,n){t?o(t):r(n.toString())}))}))},L=function(t){return r(t)?t:s()?M:T};function W(t,n,e){if(!1===g(this,W))return new W(t,n,e);var o={},i=function(t,e){return n.set(t,e),e},c=function(t){return o.resolver(o.path,t)};this.configure=function(t){o.path=t.path,o.cache=t.cache,o.resolver=L(t.resolver)},this.get=function(t){return n.exist(t)?n.resolve(t):i(t,c(t).then((function(n){return i(t,function(t,n){return r(t)?t:e.compile(t,n)}(n,t))})))},this.configure(t)}var J=[{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 _(t){if(!1===g(this,_))return new _(t);var n={};this.configure=function(t){n.withObject=t.withObject,n.rmWhitespace=t.rmWhitespace,n.token=t.token,n.vars=t.vars,n.matches=[],n.formats=[],n.slurp={match:"[ \\t]*",start:[n.token.start,"_"],end:["_",n.token.end]},J.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))})),n.regex=new RegExp(n.matches.join("|").concat("|$"),"g"),n.slurpStart=new RegExp([n.slurp.match,n.slurp.start.join("")].join(""),"gm"),n.slurpEnd=new RegExp([n.slurp.end.join(""),n.slurp.match].join(""),"gm")},this.compile=function(t,e){var r=n.vars,o=r.SCOPE,i=r.SAFE,c=r.BUFFER,u=r.COMPONENT;n.rmWhitespace&&(t=t.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=t.replace(n.slurpStart,n.token.start).replace(n.slurpEnd,n.token.end);var s,a,f,h="".concat(c,"('");s=n.regex,a=function(e,r,o){h+=m(t.slice(r,o)),e.forEach((function(t,e){t&&(h+=n.formats[e](t))}))},f=0,t.replace(s,(function(){var t=[].slice.call(arguments,0,-1),n=t.pop(),e=t.shift();return a(t,f,n),f=n+e.length,e})),h="try{".concat(h+="');","}catch(e){console.info(e)}"),n.withObject&&(h="with(".concat(o,"){").concat(h,"}")),h="".concat(c,".start();").concat(h,"return ").concat(c,".end();"),h+="\n//# sourceURL=".concat(e);var l=null;try{(l=new Function(o,u,c,i,h)).source="(function(".concat(o,",").concat(u,",").concat(c,",").concat(i,"){\n").concat(h,"\n})")}catch(t){throw t.filename=e,t.source=h,t}return l},this.configure(t)}var q="undefined"!=typeof globalThis?globalThis:window||self;function D(t){if(!1===g(this,D))return new D;var n={enabled:!0,list:{}};this.configure=function(t){n.list={},n.enabled=t.cache,!1===s()&&this.load(q[t.export])},this.load=function(t){return n.enabled&&x(n.list,t||{}),this},this.get=function(t){if(n.enabled)return n.list[t]},this.set=function(t,e){return n.enabled&&(n.list[t]=e),this},this.resolve=function(t){return Promise.resolve(this.get(t))},this.remove=function(t){delete n.list[t]},this.exist=function(t){return k(n.list,t)}}function K(t){return Promise.all(t||[]).then((function(t){return t.join("")}))}var X=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(),K(e)},e.error=function(t){throw t},e.end=function(){return K(n)},e};function Y(t){if(!1===g(this,Y))return new Y(t);this.configure=function(t,n){var e=t.vars,i=e.BLOCKS,c=e.MACRO,u=e.EXTEND,s=e.LAYOUT,a=e.BUFFER,f=e.COMPONENT;function h(t){this[i]={},this[c]={},x(this,t||{})}this.create=function(t){return new h(t)},this.helpers=function(t){x(h.prototype,t||{})},h.prototype=x({},n||{}),h.method=h.define=function(t,n,e,r,o){Object.defineProperty(h.prototype,t,{value:n,writable:e||!1,configurable:r||!1,enumerable:o||!1})},h.define(a,X()),h.define(i,{},!0),h.define(c,{},!0),h.define(s,!1,!0),h.define(u,!1,!0),h.method("getMacro",(function(){return this[c]})),h.method("getBuffer",(function(){return this[a]})),h.method("getComponent",(function(){var t=this;return f in t?function(){return t[f].apply(t,arguments)}:function(){console.log("%s function not defined",f)}})),h.method("getBlocks",(function(){return this[i]})),h.method("setExtend",(function(t){this[u]=t})),h.method("getExtend",(function(){return this[u]})),h.method("setLayout",(function(t){this[s]=t})),h.method("getLayout",(function(){return this[s]})),h.method("clone",(function(t){var n=[s,u,a];return!0===t&&n.push(i),y(this,n)})),h.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),h.method("echo",(function(){var t=this.getBuffer();[].slice.call(arguments).forEach(t)})),h.method("fn",(function(t){var n=this.getBuffer(),e=this;return function(){return n.backup(),r(t)&&t.apply(e,arguments),n.restore()}})),h.method("get",(function(t,n){var e=b(this,t,!0),r=e.shift(),o=e.pop();return k(r,o)?r[o]:n})),h.method("set",(function(t,n){var e=b(this,t,!1),r=e.shift(),o=e.pop();return this.getExtend()&&k(r,o)?r[o]:r[o]=n})),h.method("macro",(function(t,n){var e=this.getMacro(),r=this.fn(n),o=this;e[t]=function(){return o.echo(r.apply(void 0,arguments))}})),h.method("call",(function(t){var n=this.getMacro()[t],e=[].slice.call(arguments,1);if(r(n))return n.apply(n,e)})),h.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 o=Object.assign([],r[t]),i=function(){return o.shift()};this.echo(i()(function t(){var n=i();return n?function(){e.echo(n(t()))}:E}()))}})),h.method("include",(function(t,n,e){var r=!1===e?{}:this.clone(!0),o=x(r,n||{}),i=this.render(t,o);this.echo(i)})),h.method("use",(function(t,n){var e=this.require(t);this.echo(O(e,(function(t){var e=this.getMacro();j(t,(function(t,r){e[[n,r].join(".")]=t}))}),this))})),h.method("async",(function(t,n){this.echo(O(t,(function(t){return this.fn(n)(t)}),this))})),h.method("node",(function(t,n,e){return U(t,n,e)})),h.method("el",(function(t,n,e){r(e)&&(e=this.fn(e)()),this.echo(O(e,(function(e){return U(t,n,e)}),this))})),h.method("each",(function(t,n){o(t)&&(t=this.get(t,[])),j(t,n)}))},this.configure(t)}function V(t){if(!1===g(this,V))return new V(t);var n={},e={};A(e,t||{});var r=new Y(e),o=new _(e),i=new D,c=new W(e,i,o),u=function(t,n){return c.get(t).then((function(t){return t.call(n,n,n.getComponent(),n.getBuffer(),v)}))},s=function t(n,o){var i=w(n,e.extension),c=r.create(o);return u(i,c).then((function(n){if(c.getExtend()){c.setExtend(!1);var e=c.getLayout(),r=c.clone();return t(e,r)}return n}))};this.configure=function(t){return A(e,t=t||{}),r.configure(e,n),o.configure(e),i.configure(e),c.configure(e),e},this.render=function(t,n){return s(t,n)},this.helpers=function(t){r.helpers(Object.assign(n,t||{}))},this.preload=function(t){return i.load(t||{})},this.create=function(t){return new V(t)},this.compile=function(t,n){return o.compile(t,n)},this.context=function(t){return r.create(t)},this.helpers({require:function(t){var n=w(t,e.extension),o=r.create({});return u(n,o).then((function(){return o.getMacro()}))},render:s})}var z=new V,G=z.render,H=z.context,I=z.compile,Q=z.helpers,Z=z.preload,tt=z.configure,nt=z.create;t.EJS=V,t.__express=function(t,c,u){r(c)&&(u=c,c={});var s=x({},(c=c||{}).settings),a=e(o,F.path,s.views),f=e(i,F.cache,s["view cache"]),h=x({},s["view options"]),l=n.relative(a,t);return h.path=a,h.cache=f,tt(h),this.render(l,c).then((function(t){u(null,t)})).catch((function(t){u(t)}))},t.compile=I,t.configure=tt,t.context=H,t.create=nt,t.element=U,t.helpers=Q,t.preload=Z,t.render=G,t.safeValue=v}));
|
package/package.json
CHANGED