@kosatyi/ejs 0.0.12 → 0.0.14

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.min.js CHANGED
@@ -1 +1 @@
1
- !function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n="undefined"!=typeof globalThis?globalThis:n||self).ejs=t()}(this,(function(){"use strict";var n={},t={export:"ejs.precompiled",cache:!0,path:"views",resolver:null,extension:{template:"ejs",module:"mjs"},vars:{EXTEND:"$$$",BUFFER:"$$a",OUTPUT:"$$i",LAYOUT:"$$l",MACROS:"$$m",PRINT:"$$j",BLOCKS:"$$b",ERROR:"$$e",SCOPE:"$$s",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},e=function(){var n=[].slice.call(arguments),t=n.shift();return n.filter(t).pop()},r=function(n){return"function"==typeof n},o=function(n){return"string"==typeof n},i=function(n){return"boolean"==typeof n},u=new Function("try {return this===global;}catch(e){return false;}"),c={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},a={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},s=function(n){return new RegExp(["[",Object.keys(n).join(""),"]"].join(""),"g")},f=s(a),l=s(c),h=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(""+n).replace(f,(function(n){return a[n]}))},p=function(n,t,e){return null==(e=n)?"":t?h(e):e},v=function(n,t){var e=n,r=t.split("."),o=r.pop();return r.forEach((function(n){e=e[n]=e[n]||{}})),[e,o]},d=function(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];var r=t.shift();return t.filter((function(n){return n})).reduce((function(n,t){return Object.assign(n,t)}),r)},g=function(n,t){var e;for(e in n)b(n,e)&&t(n[e],e,n)},m=function(n,t){return function(n,t,e){var r=n instanceof Array,o=r?[]:{};return g(n,(function(n,e,i){var u=t(n,e,i);void 0!==u&&(r?o.push(u):o[e]=u)})),o}(n,(function(n,e){if(-1===t.indexOf(e))return n}))},b=function(n,t){return n&&n.hasOwnProperty(t)},w=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],x=" ",y='"',E="/",j="<",$=">";function O(n,t,e){var r=[],o=-1===w.indexOf(n),i=function(n,t,e){var r=[];return g(n,(function(n,e,o){var i=t(n,e,o);void 0!==i&&r.push(i)})),r}(t,(function(n,t){if(null!=n)return[h(t),[y,h(n),y].join("")].join("=")})).join(x);return r.push([j,n,x,i,$].join("")),e&&r.push(e instanceof Array?e.join(""):e),o&&r.push([j,E,n,$].join("")),r.join("")}var k=[{symbol:"-",format:function(n){return"'+\n".concat(this.SAFE,"(").concat(n,",1)+\n'")}},{symbol:"=",format:function(n){return"'+\n".concat(this.SAFE,"(").concat(n,")+\n'")}},{symbol:"#",format:function(n){return"'+\n/**".concat(n,"**/+\n'")}},{symbol:"",format:function(n){return"')\n".concat(n,"\n").concat(this.BUFFER,"('")}}],F=function(n){var t=n.token,e=n.vars,r=n.extension.module,o=[],i=[],u={match:"[ \\t]*",start:[t.start,"_"],end:["_",t.end]};k.forEach((function(n){o.push(t.start.concat(n.symbol).concat(t.regex).concat(t.end)),i.push(n.format.bind(e))}));var a=new RegExp(o.join("|").concat("|$"),"g"),s=new RegExp([u.match,u.start].join(""),"gm"),f=new RegExp([u.end,u.match].join(""),"gm");return function(n,o){var h=e.SCOPE,p=e.SAFE,v=e.BUFFER,d=o.split(".").pop();n=(n=n.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")).replace(s,u.start).replace(f,u.end),d===r&&(n=[t.start,n,t.end].join("\n"));var g="".concat(v,"('");!function(n,t,e){var r=0;t.replace(n,(function(){var n=[].slice.call(arguments,0,-1),t=n.pop(),o=n.shift();return e(n,r,t),r=t+o.length,o}))}(a,n,(function(t,e,r){g+=(""+n.slice(e,r)).replace(l,(function(n){return"\\"+c[n]})),t.forEach((function(n,t){n&&(g+=i[t](n))}))})),g+="');",g="with(".concat(h,"){").concat(g,"}"),g="".concat(v,".start();").concat(g,"return ").concat(v,".end();"),g+="\n//# sourceURL=".concat(o);var m=null;try{(m=new Function(h,v,p,g)).source="(function(".concat(h,",").concat(v,",").concat(p,"){\n").concat(g,"\n})")}catch(n){throw n.filename=o,n.source=g,n}return m}},R=function(n){return window.fetch(n).then((function(n){return n.text()}))},B=function(t){return new Promise((function(e,r){n.readFile(t,(function(n,t){n?r(n):e(t.toString())}))}))},S=function(t,e){return n.watch(".",{cwd:t}).on("change",(function(n){e.remove(n)})).on("error",(function(n){console.log("watcher error: "+n)}))},_=function(n,t,e){var o=n.path;n.token;var i=r(n.resolver)?n.resolver:u()?B:R,c=function(n){return i(function(n){return(n=[o,n].join("/")).replace(/\/\//g,"/")}(n))},a=function(n,e){return t.set(e,n),n};return n.watch&&u()&&S(o,t),function(n){if(t.exist(n))return t.resolve(n);var r=c(n).then((function(t){return a(e(t,n),n)}));return a(r,n)}};function A(n,t,e){return t in n?Object.defineProperty(n,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[t]=e,n}var L=function(n){return Promise.all(n).then((function(n){return n.join("")}))},P=function(){var n=[],t=[];function e(n){t.push(n)}return e.start=function(){t=[]},e.backup=function(){n.push(t.concat()),t=[]},e.restore=function(){var e=t.concat();return t=n.pop(),L(e)},e.end=function(){return L(t)},e},T=function(n,t){var e,i=n.vars,u=i.EXTEND,c=i.MACROS,a=i.LAYOUT,s=i.BLOCKS,f=i.BUFFER;function l(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setBlocks({}),d(this,n),this.setLayout(!1),this.setExtend(!1)}return Object.defineProperties(l.prototype,(A(e={},f,{value:P(),writable:!1,configurable:!1,enumerable:!1}),A(e,"getBuffer",{value:function(){return this[f]},writable:!1,configurable:!1}),A(e,"setBlocks",{value:function(n){this[s]=n},writable:!1,configurable:!1}),A(e,"getBlocks",{value:function(){return this[s]},writable:!1,configurable:!1}),A(e,"setExtend",{value:function(n){this[u]=n},writable:!1,configurable:!1}),A(e,"getExtend",{value:function(){return this[u]},writable:!1,configurable:!1}),A(e,"setLayout",{value:function(n){this[a]=n},writable:!1,configurable:!1}),A(e,"getLayout",{value:function(){return this[a]},writable:!1,configurable:!1}),e)),l.helpers=function(n){d(l.prototype,n)},l.helpers(t),l.helpers({clone:function(n){var t=[a,u,c,f];return!0===n&&t.push(s),m(this,t)},echo:function(){var n=this.getBuffer(),t=[].slice.call(arguments);t.forEach((function(t){n(t)}))},macro:function(n,t){var e=this.getBuffer(),o=function(){e.backup(),r(n)&&n.apply(this,arguments);var o=e.restore();return!0===t?this.echo(o):o}.bind(this);return o.__context=this,o.__source=n,o.__layout=this.getLayout(),o},resolve:function(n,t){return Promise.resolve(n).then(t.bind(this))},async:function(n,t){var e=this;this.echo(this.resolve(n,(function(n){return e.macro(t)(n)})))},node:O,element:function(n,t,e){r(e)&&(e=this.macro(e)()),this.echo(this.resolve(e,(function(e){return O(n,t,e)})))},component:function(n,t){t=function(n){var t=d({},n.props);return{element:O,create:n.create,render:function(n){return this.create(d({},t,n))}}}(t),this.set(n,function(n){this.echo(t.render(n))}.bind(this))},get:function(n,t){var e=v(this,n),r=e.shift(),o=e.pop();return b(r,o)?r[o]:t},set:function(n,t){var e=v(this,n),r=e.shift(),o=e.pop();if(this.getExtend()&&b(r,o))return r[o];r[o]=t},call:function(n){var t=[].slice.call(arguments,1),e=v(this,n),o=e.shift(),i=e.pop();if(r(o[i]))return o[i].apply(o,t)},each:function(n,t){o(n)&&(n=this.get(n,[])),g(n,t)},extend:function(n){this.setExtend(!0),this.setLayout(n)},block:function(n,t){var e=this.getBlocks();if(e[n]=e[n]||[],e[n].push(this.macro(t)),!1===this.getExtend()){var r=e[n];this.echo(r.shift()(function n(){var t=r.shift();if(t){var e=t.__context;return function(){e.echo(t(n()))}}return function(){}}()))}},include:function(n,t,e){var r=!1===e?{}:this.clone(!0),o=d(r,t||{}),i=this.render(n,o);this.echo(i)},use:function(n){var t=this,e=this.require(n);return this.echo(e),{as:function(n){return e.then((function(e){t.set(n,e)})),this}}},from:function(n){var t=this,e=this.require(n);return this.echo(e),{use:function(){var n=[].slice.call(arguments);return e.then((function(e){n.forEach((function(n){t.set(n,e[n])}))})),this}}}}),l};var U,q,C,N,D,K=(q={},C={},N=function(n,t){var e=n.split(".").pop();return e!==t&&(n=[n,t].join(".")),n},D={element:O,output:function(n,t){return D.template(n).then((function(n){return n.call(t,t,t.getBuffer(),p)}))},render:function(n,t){var e=N(n,q.extension.template),r=new D.scope(t);return D.output(e,r).then((function(n){if(r.getExtend()){r.setExtend(!1);var t=r.getLayout(),e=r.clone();return D.render(t,e)}return n}))},require:function(n){var t=N(n,q.extension.module),e=new D.scope({});return D.output(t,e).then((function(){return e.clone(!0)}))},helpers:function(n){d(C,n=n||{}),D.scope.helpers(n)},configure:function(n){return q.export=e(o,t.export,n.export),q.path=e(o,t.path,n.path),q.resolver=e(r,t.resolver,n.resolver),q.extension=d({},t.extension,n.extension),q.token=d({},t.token,n.token),q.vars=d({},t.vars,n.vars),D.scope=T(q,C),D.compile=F(q),D.wrapper=function(n){var t=n.export;return function(n){var e="(function(o){\n";return n.forEach((function(n){e+="o["+JSON.stringify(n.name)+"]="+String(n.content)+"\n"})),e+='})(window["'+t+'"] = window["'+t+'"] || {});\n'}}(q),D.cache=function(n){var t=n.export,e={};return{preload:function(){return!1===u()&&this.load(window[t]),this},exist:function(n){return b(e,n)},get:function(n){return e[n]},remove:function(n){delete e[n]},resolve:function(n){return Promise.resolve(this.get(n))},set:function(n,t){return e[n]=t,this},load:function(n){return d(e,n),this}}.preload()}(q),D.template=_(q,D.cache,D.compile),D},__express:function(u,c,a){r(c)&&(a=c,c={});var s=d({},(c=c||{}).settings),f=e(o,s.views,t.path),l=e(i,s["view cache"],t.cache),h=d({},s["view options"]),p=n.relative(f,u);return h.path=f,h.cache=l,D.configure(h),D.render(p,c).then((function(n){a(null,n)})).catch((function(n){a(n)}))}},D.configure(U||{}),D.helpers({require:function(n){return D.require(n,this)},render:function(n,t){return D.render(n,t)}}),D);return K}));
1
+ !function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(n="undefined"!=typeof globalThis?globalThis:n||self).ejs=t()}(this,(function(){"use strict";var n={},t={export:"ejs.precompiled",cache:!0,path:"views",resolver:null,extension:"ejs",vars:{EXTEND:"$$$",BUFFER:"$$a",OUTPUT:"$$i",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",ERROR:"$$e",SCOPE:"$$s",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},e=function(){var n=[].slice.call(arguments),t=n.shift();return n.filter(t).pop()},r=function(n){return"function"==typeof n},o=function(n){return"string"==typeof n},i=function(n){return"boolean"==typeof n},c=new Function("try {return this===global;}catch(e){return false;}"),u={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},a={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},f=function(n){return new RegExp(["[",Object.keys(n).join(""),"]"].join(""),"g")},s=f(a),h=f(u),l=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(""+n).replace(s,(function(n){return a[n]}))},p=function(n,t,e){return null==(e=n)?"":t?l(e):e},v=function(n,t){var e=n,r=t.split("."),o=r.pop();return r.forEach((function(n){e=e[n]=e[n]||{}})),[e,o]},d=function(){for(var n=arguments.length,t=new Array(n),e=0;e<n;e++)t[e]=arguments[e];var r=t.shift();return t.filter((function(n){return n})).reduce((function(n,t){return Object.assign(n,t)}),r)},m=function(){},g=function(n,t){var e;for(e in n)w(n,e)&&t(n[e],e,n)},b=function(n,t){return function(n,t,e){var r=n instanceof Array,o=r?[]:{};return g(n,(function(n,e,i){var c=t(n,e,i);void 0!==c&&(r?o.push(c):o[e]=c)})),o}(n,(function(n,e){if(-1===t.indexOf(e))return n}))},y=function(n,t,e){return Promise.resolve(n).then(t.bind(e))},w=function(n,t){return n&&n.hasOwnProperty(t)},x=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],E=" ",j='"',$="/",O="<",k=">";function F(n,t,e){var r=[],o=-1===x.indexOf(n),i=function(n,t,e){var r=[];return g(n,(function(n,e,o){var i=t(n,e,o);void 0!==i&&r.push(i)})),r}(t,(function(n,t){if(null!=n)return[l(t),[j,l(n),j].join("")].join("=")})).join(E);return r.push([O,n,E,i,k].join("")),e&&r.push(e instanceof Array?e.join(""):e),o&&r.push([O,$,n,k].join("")),r.join("")}var B=[{symbol:"-",format:function(n){return"'+\n".concat(this.SAFE,"(").concat(n,",1)+\n'")}},{symbol:"=",format:function(n){return"'+\n".concat(this.SAFE,"(").concat(n,")+\n'")}},{symbol:"#",format:function(n){return"'+\n/**".concat(n,"**/+\n'")}},{symbol:"",format:function(n){return"')\n".concat(n,"\n").concat(this.BUFFER,"('")}}],R=function(n){var t=n.token,e=n.vars,r=[],o=[],i={match:"[ \\t]*",start:[t.start,"_"],end:["_",t.end]};B.forEach((function(n){r.push(t.start.concat(n.symbol).concat(t.regex).concat(t.end)),o.push(n.format.bind(e))}));var c=new RegExp(r.join("|").concat("|$"),"g"),a=new RegExp([i.match,i.start].join(""),"gm"),f=new RegExp([i.end,i.match].join(""),"gm");return function(n,t){var r=e.SCOPE,s=e.SAFE,l=e.BUFFER;n=(n=n.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")).replace(a,i.start).replace(f,i.end);var p="".concat(l,"('");!function(n,t,e){var r=0;t.replace(n,(function(){var n=[].slice.call(arguments,0,-1),t=n.pop(),o=n.shift();return e(n,r,t),r=t+o.length,o}))}(c,n,(function(t,e,r){p+=(""+n.slice(e,r)).replace(h,(function(n){return"\\"+u[n]})),t.forEach((function(n,t){n&&(p+=o[t](n))}))})),p="try{".concat(p+="');","}catch(e){console.info(e)}"),p="with(".concat(r,"){").concat(p,"}"),p="".concat(l,".start();").concat(p,"return ").concat(l,".end();"),p+="\n//# sourceURL=".concat(t);var v=null;try{(v=new Function(r,l,s,p)).source="(function(".concat(r,",").concat(l,",").concat(s,"){\n").concat(p,"\n})")}catch(n){throw console.log(n),n.filename=t,n.source=p,n}return v}},S=function(n){return window.fetch(n).then((function(n){return n.text()}))},A=function(t){return new Promise((function(e,r){n.readFile(t,(function(n,t){n?r(n):e(t.toString())}))}))},P=function(t,e){return n.watch(".",{cwd:t}).on("change",(function(n){e.remove(n)})).on("error",(function(n){console.log("watcher error: "+n)}))},L=function(n,t,e){var o=n.path;n.token;var i=r(n.resolver)?n.resolver:c()?A:S,u=function(n){return i(function(n){return(n=[o,n].join("/")).replace(/\/\//g,"/")}(n))},a=function(n,e){return t.set(e,n),n};return n.watch&&c()&&P(o,t),function(n){if(t.exist(n))return t.resolve(n);var r=u(n).then((function(t){return a(e(t,n),n)}));return a(r,n)}},M=function(n){return Promise.all(n).then((function(n){return n.join("")}))},U=function(){var n=[],t=[];function e(n){t.push(n)}return e.start=function(){t=[]},e.backup=function(){n.push(t.concat()),t=[]},e.restore=function(){var e=t.concat();return t=n.pop(),M(e)},e.error=function(n){throw n},e.end=function(){return M(t)},e};var T,C,q,_,N,D=(C={},q={},_=function(n,t){var e=n.split(".").pop();return e!==t&&(n=[n,t].join(".")),n},N={element:F,output:function(n,t){return N.template(n).then((function(n){return n.call(t,t,t.getBuffer(),p)}))},render:function(n,t){var e=_(n,C.extension),r=new N.scope(t);return N.output(e,r).then((function(n){if(r.getExtend()){r.setExtend(!1);var t=r.getLayout(),e=r.clone();return N.render(t,e)}return n}))},require:function(n){var t=_(n,C.extension),e=new N.scope({});return N.output(t,e).then((function(){return e.getMacro()}))},helpers:function(n){d(q,n=n||{}),N.scope.helpers(n)},configure:function(n){return C.export=e(o,t.export,n.export),C.path=e(o,t.path,n.path),C.resolver=e(r,t.resolver,n.resolver),C.extension=e(o,t.extension,n.extension),C.token=d({},t.token,n.token),C.vars=d({},t.vars,n.vars),N.scope=function(n,t){var e=n.vars,i=e.EXTEND,c=e.LAYOUT,u=e.BLOCKS,a=e.BUFFER,f=e.MACRO;function s(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),d(this,n)}return e.SCOPE,s.helpers=function(n){d(s.prototype,n)},s.property=function(n,t){Object.defineProperty(s.prototype,n,t)},s.method=function(n,t){return s.property(n,{value:t,writable:!1,configurable:!1,enumerable:!1})},s.property(a,{value:U(),writable:!1,configurable:!1,enumerable:!1}),s.property(u,{value:{},writable:!0,configurable:!1,enumerable:!1}),s.property(f,{value:{},writable:!0,configurable:!1,enumerable:!1}),s.property(c,{value:!1,writable:!0,configurable:!1,enumerable:!1}),s.property(i,{value:!1,writable:!0,configurable:!1,enumerable:!1}),s.method("initBlocks",(function(){this[u]={}})),s.method("initMacro",(function(){this[f]={}})),s.method("getMacro",(function(){return this[f]})),s.method("getBuffer",(function(){return this[a]})),s.method("getBlocks",(function(){return this[u]})),s.method("setExtend",(function(n){this[i]=n})),s.method("getExtend",(function(){return this[i]})),s.method("setLayout",(function(n){this[c]=n})),s.method("getLayout",(function(){return this[c]})),s.method("clone",(function(n){var t=[c,i,a];return!0===n&&t.push(u),b(this,t)})),s.method("extend",(function(n){this.setExtend(!0),this.setLayout(n)})),s.method("echo",(function(){var n=this.getBuffer();[].slice.call(arguments).forEach((function(t){n(t)}))})),s.method("fn",(function(n){var t=this.getBuffer(),e=this;return function(){return t.backup(),r(n)&&n.apply(e,arguments),t.restore()}})),s.method("get",(function(n,t){var e=v(this,n),r=e.shift(),o=e.pop();return w(r,o)?r[o]:t})),s.method("set",(function(n,t){var e=v(this,n),r=e.shift(),o=e.pop();return this.getExtend()&&w(r,o)?r[o]:r[o]=t})),s.method("macro",(function(n,t){var e=this.getMacro(),r=this.fn(t),o=this;e[n]=function(){return o.echo(r.apply(void 0,arguments))}})),s.method("call",(function(n){var t=this.getMacro()[n],e=[].slice.call(arguments,1);if(r(t))return t.apply(t,e)})),s.method("block",(function(n,t){var e=this,r=this.getBlocks();if(r[n]=r[n]||[],r[n].push(this.fn(t)),!this.getExtend()){var o=Object.assign([],r[n]),i=function(){return o.shift()};this.echo(i()(function n(){var t=i();return t?function(){e.echo(t(n()))}:m}()))}})),s.method("include",(function(n,t,e){var r=!1===e?{}:this.clone(!0),o=d(r,t||{}),i=this.render(n,o);this.echo(i)})),s.method("use",(function(n,t){var e=this.require(n);this.echo(y(e,(function(n){var e=this.getMacro();g(n,(function(n,r){e[[t,r].join(".")]=n}))}),this))})),s.method("async",(function(n,t){this.echo(y(n,(function(n){return this.fn(t)(n)}),this))})),s.helpers(t),s.helpers({el:function(n,t,e){r(e)&&(e=this.fn(e)()),this.echo(y(e,(function(e){return F(n,t,e)}),this))},each:function(n,t){o(n)&&(n=this.get(n,[])),g(n,t)}}),s}(C,q),N.compile=R(C),N.wrapper=function(n){var t=n.export;return function(n){var e="(function(o){\n";return n.forEach((function(n){e+="o["+JSON.stringify(n.name)+"]="+String(n.content)+"\n"})),e+='})(window["'+t+'"] = window["'+t+'"] || {});\n'}}(C),N.cache=function(n){var t=n.export,e={};return{preload:function(){return!1===c()&&this.load(window[t]),this},exist:function(n){return w(e,n)},get:function(n){return e[n]},remove:function(n){delete e[n]},resolve:function(n){return Promise.resolve(this.get(n))},set:function(n,t){return e[n]=t,this},load:function(n){return d(e,n),this}}.preload()}(C),N.template=L(C,N.cache,N.compile),N},__express:function(c,u,a){r(u)&&(a=u,u={});var f=d({},(u=u||{}).settings),s=e(o,f.views,t.path),h=e(i,f["view cache"],t.cache),l=d({},f["view options"]),p=n.relative(s,c);return l.path=s,l.cache=h,N.configure(l),N.render(p,u).then((function(n){a(null,n)})).catch((function(n){a(n)}))}},N.configure(T||{}),N.helpers({require:function(n){return N.require(n,this)},render:function(n,t){return N.render(n,t)}}),N);return D}));