@kosatyi/ejs 0.0.61 → 0.0.63
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/element.js +3 -2
- package/dist/cjs/index.js +450 -665
- package/dist/esm/element.js +3 -2
- package/dist/esm/index.js +306 -315
- package/dist/templates.js +1 -0
- package/dist/umd/element.js +3 -2
- package/dist/umd/element.min.js +1 -1
- package/dist/umd/index.js +451 -666
- package/dist/umd/index.min.js +1 -1
- package/package.json +3 -2
- package/type/global.d.ts +0 -101
- package/type/index.d.ts +0 -5
package/dist/umd/index.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";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(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,s(r.key),r)}}function i(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function o(t,e,n){return(e=s(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function u(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return c(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,u=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return u=t.done,t},e:function(t){s=!0,o=t},f:function(){try{u||null==n.return||n.return()}finally{if(s)throw o}}}}function s(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=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},h=function(t){return"function"==typeof t},f=function(t){return"string"==typeof t},l=function(t){return"boolean"==typeof t},p=function(t){return"object"===e(t)},v=function(t){return void 0===t},d="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),m=function(){return d},g={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},y={"&":"&","<":"<",">":">",'"':""","'":"'"},b=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},w=b(y),k=b(g),x=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(w,(function(t){return y[t]}))},j=function(t,e,n){return null==(n=t)?"":e?x(n):n},E=function(t,e,n){var r,i=t,o=String(e).split("."),c=o.pop(),s=u(o);try{for(s.s();!(r=s.n()).done;){var a=r.value;if(n&&!1===i.hasOwnProperty(a)){i={};break}i=i[a]=i[a]||{}}}catch(t){s.e(t)}finally{s.f()}return[i,c]},O=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},S=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)},F=function(){},B=function(t,e){var n;for(n in t)R(t,n)&&e(t[n],n,t)},P=function(t,e){return function(t,e,n){var r=t instanceof Array,i=r?[]:{};return B(t,(function(t,n,o){var c=e(t,n,o);!1===v(c)&&(r?i.push(c):i[n]=c)})),i}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},A=function(t,e,n){return Promise.resolve(t).then(e.bind(n))},R=function(t,e){return t&&t.hasOwnProperty(e)},$={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]+?)"}},T=function(t,e){S(t,{path:a(f,$.path,t.path,e.path),export:a(f,$.export,t.export,e.export),resolver:a(h,$.resolver,t.resolver,e.resolver),extension:a(f,$.extension,t.extension,e.extension),withObject:a(l,$.withObject,t.withObject,e.withObject),rmWhitespace:a(l,$.rmWhitespace,t.rmWhitespace,e.rmWhitespace),watch:a(l,$.watch,t.watch,e.watch),chokidar:a(p,$.export,t.export,e.export),token:S({},$.token,t.token,e.token),vars:S({},$.vars,t.vars,e.vars)})},C={},M=function(t,e){return e=(e=[t,e].join("/")).replace(/\/\//g,"/")},U=function(t,e){return fetch(M(t,e)).then((function(t){return t.text()}))},_=function(t,e){return new Promise((function(n,r){C.readFile(M(t,e),(function(t,e){t?r(t):n(e.toString())}))}))},L=function(){function t(e,r,i){n(this,t),this.cache=r,this.watcher={unwatch:function(){},on:function(){}},this.compiler=i,this.configure(e)}return i(t,[{key:"configure",value:function(t){var e=this;this.path=t.path,this.chokidar=t.chokidar,this.resolver=h(t.resolver)?t.resolver:m()?_:U,t.watch&&m()&&(this.watcher&&this.watcher.unwatch("."),this.chokidar&&(this.watcher=this.chokidar.watch(".",{cwd:this.path}).on("change",(function(t){e.cache.remove(t)}))))}},{key:"resolve",value:function(t){return this.resolver(this.path,t)}},{key:"result",value:function(t,e){return this.cache.set(t,e),e}},{key:"compile",value:function(t,e){return h(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}(),N=[{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,"('")}}],W=function(){function t(e){n(this,t),this.configure(e)}return i(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]},N.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,h,f="".concat(c,"('");s=this.regex,a=function(e,r,i){f+=(""+t.slice(r,i)).replace(k,(function(t){return"\\"+g[t]})),e.forEach((function(t,e){t&&(f+=n.formats[e](t))}))},h=0,t.replace(s,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return a(t,h,e),h=e+n.length,n})),f="try{".concat(f+="');","}catch(e){console.info(e)}"),this.withObject&&(f="with(".concat(i,"){").concat(f,"}")),f="".concat(c,".start();").concat(f,"return ").concat(c,".end();"),f+="\n//# sourceURL=".concat(e);var l=null;try{(l=new Function(i,u,c,o,f)).source="(function(".concat(i,",").concat(u,",").concat(c,",").concat(o,"){\n").concat(f,"\n})")}catch(t){throw t.filename=e,t.source=f,t}return l}}]),t}(),q="undefined"!=typeof globalThis?globalThis:window||self,I=function(){function t(e){n(this,t),o(this,"list",{}),this.configure(e),!1===m()&&this.load(q[this.namespace])}return i(t,[{key:"configure",value:function(t){this.list={},this.namespace=t.export}},{key:"load",value:function(t){return S(this.list,t),this}},{key:"exist",value:function(t){return R(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}(),D=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],K=" ",X='"',Y="/",J="<",V=">",z=function(t,e,n){var r=[],i=-1===D.indexOf(t),o=function(t,e,n){var r=[];return B(t,(function(t,n,i){var o=e(t,n,i);!1===v(o)&&r.push(o)})),r}(e,(function(t,e){if(null!=t)return[x(e),[X,x(t),X].join("")].join("=")})).join(K);return r.push([J,t,K,o,V].join("")),n&&r.push(n instanceof Array?n.join(""):n),i&&r.push([J,Y,t,V].join("")),r.join("")},G=function(t){return Promise.all(t).then((function(t){return t.join("")}))},H=function(){function t(e){n(this,t),this.configure(e)}return i(t,[{key:"configure",value:function(t,e){var n=t.vars,r=n.EXTEND,i=n.LAYOUT,o=n.BLOCKS,c=n.BUFFER,u=n.MACRO,s=n.COMPONENT;function a(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),S(this,t)}this.create=function(t){return new a(t)},this.helpers=function(t){S(a.prototype,t)},a.prototype=S({},e||{}),a.define=a.method=function(t,e,n,r,i){return Object.defineProperty(a.prototype,t,{value:e,writable:n||!1,configurable:r||!1,enumerable:i||!1})},a.define(c,function(){var t=[],e=[];function n(t){e.push(t)}return n.start=function(){e=[]},n.backup=function(){t.push(e.concat()),e=[]},n.restore=function(){var n=e.concat();return e=t.pop(),G(n)},n.error=function(t){throw t},n.end=function(){return G(e)},n}()),a.define(o,{},!0),a.define(u,{},!0),a.define(i,!1,!0),a.define(r,!1,!0),a.method("initBlocks",(function(){this[o]={}})),a.method("initMacro",(function(){this[u]={}})),a.method("getMacro",(function(){return this[u]})),a.method("getBuffer",(function(){return this[c]})),a.method("getComponent",(function(){var t=this;return s in t?function(){return t[s].apply(t,arguments)}:function(){console.log("%s function not defined",s)}})),a.method("getBlocks",(function(){return this[o]})),a.method("setExtend",(function(t){this[r]=t})),a.method("getExtend",(function(){return this[r]})),a.method("setLayout",(function(t){this[i]=t})),a.method("getLayout",(function(){return this[i]})),a.method("clone",(function(t){var e=[i,r,c];return!0===t&&e.push(o),P(this,e)})),a.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),a.method("echo",(function(){var t=this.getBuffer();[].slice.call(arguments).forEach(t)})),a.method("fn",(function(t){var e=this.getBuffer(),n=this;return function(){return e.backup(),h(t)&&t.apply(n,arguments),e.restore()}})),a.method("get",(function(t,e){var n=E(this,t,!0),r=n.shift(),i=n.pop();return R(r,i)?r[i]:e})),a.method("set",(function(t,e){var n=E(this,t,!1),r=n.shift(),i=n.pop();return this.getExtend()&&R(r,i)?r[i]:r[i]=e})),a.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))}})),a.method("call",(function(t){var e=this.getMacro()[t],n=[].slice.call(arguments,1);if(h(e))return e.apply(e,n)})),a.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()))}:F}()))}})),a.method("include",(function(t,e,n){var r=!1===n?{}:this.clone(!0),i=S(r,e||{}),o=this.render(t,i);this.echo(o)})),a.method("use",(function(t,e){var n=this.require(t);this.echo(A(n,(function(t){var n=this.getMacro();B(t,(function(t,r){n[[e,r].join(".")]=t}))}),this))})),a.method("async",(function(t,e){this.echo(A(t,(function(t){return this.fn(e)(t)}),this))})),a.method("node",(function(t,e,n){return z(t,e,n)})),a.method("el",(function(t,e,n){h(n)&&(n=this.fn(n)()),this.echo(A(n,(function(n){return z(t,e,n)}),this))})),a.method("each",(function(t,e){f(t)&&(t=this.get(t,[])),B(t,e)}))}}]),t}(),Q=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,t),o(this,"export",["cache","render","require","helpers","configure","preload","compile","create","__express"]),this.config={},this.scope={},T(this.config,e),function(t,e){(arguments.length>2&&void 0!==arguments[2]?arguments[2]:[]).forEach((function(n){n in t&&(t[n]=t[n].bind(e))}))}(this,this,this.export),this.context=new H(this.config),this.compiler=new W(this.config),this.cache=new I(this.config),this.template=new L(this.config,this.cache,this.compiler),this.helpers({require:this.require,render:this.render})}return i(t,[{key:"configure",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return T(this.config,t),this.context.configure(this.config,this.scope),this.compiler.configure(this.config),this.cache.configure(this.config),this.template.configure(this.config),this.config}},{key:"output",value:function(t,e){return this.template.get(t).then((function(t){return t.call(e,e,e.getComponent(),e.getBuffer(),j)}))}},{key:"render",value:function(t,e){var n=this,r=O(t,this.config.extension),i=this.context.create(e);return this.output(r,i).then((function(t){if(i.getExtend()){i.setExtend(!1);var e=i.getLayout(),r=i.clone();return n.render(e,r)}return t}))}},{key:"require",value:function(t){var e=O(t,this.config.extension),n=this.context.create({});return this.output(e,n).then((function(){return n.getMacro()}))}},{key:"create",value:function(){return new t(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}},{key:"helpers",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.context.helpers(S(this.scope,t))}},{key:"preload",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return this.cache.load(t)}},{key:"compile",value:function(t,e){return this.compiler.compile(t,e)}},{key:"__express",value:function(t,e,n){h(e)&&(n=e,e={});var r=S({},(e=e||{}).settings),i=a(f,$.path,r.views),o=a(l,$.cache,r["view cache"]),c=S({},r["view options"]),u=C.relative(i,t);return c.path=i,c.cache=o,this.configure(c),this.render(u,e).then((function(t){n(null,t)})).catch((function(t){n(t)}))}}]),t}(),Z=new Q({}),tt=Z.__express,et=Z.render,nt=Z.context,rt=Z.compile,it=Z.helpers,ot=Z.preload,ct=Z.configure,ut=Z.create;t.EJS=Q,t.__express=tt,t.compile=rt,t.configure=ct,t.context=nt,t.create=ut,t.element=z,t.helpers=it,t.preload=ot,t.render=et,t.safeValue=j}));
|
|
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}));
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "EJS Templates",
|
|
4
4
|
"homepage": "https://github.com/kosatyi/ejs",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.63",
|
|
7
7
|
"main": "dist/cjs/index.js",
|
|
8
8
|
"module": "dist/esm/index.js",
|
|
9
9
|
"browser": "dist/umd/index.js",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@kosatyi/is-type": "^0.0.5",
|
|
54
|
-
"chokidar": "^3.5.3"
|
|
54
|
+
"chokidar": "^3.5.3",
|
|
55
|
+
"ejs": "npm:@kosatyi/ejs@^0.0.62"
|
|
55
56
|
}
|
|
56
57
|
}
|
package/type/global.d.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
/**
|
|
3
|
-
* extend layout with blocks in current template file
|
|
4
|
-
* @param layout
|
|
5
|
-
*/
|
|
6
|
-
function extend(layout: string): any
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* define block with custom **name** and callback
|
|
10
|
-
* @param name
|
|
11
|
-
* @param [callback]
|
|
12
|
-
*/
|
|
13
|
-
function block(name: string, callback?: Function): any
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* set property in current scope
|
|
17
|
-
* @param path
|
|
18
|
-
* @param value
|
|
19
|
-
*/
|
|
20
|
-
function set(path: string, value: any): any
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* get property in current scope
|
|
24
|
-
* @param path
|
|
25
|
-
* @param defaults
|
|
26
|
-
*/
|
|
27
|
-
function get(path: string, defaults?: any): any
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* import macro from file **path** and set to current scope **name** property
|
|
31
|
-
* @param path
|
|
32
|
-
* @param name
|
|
33
|
-
*/
|
|
34
|
-
function use(path: string, name: string): any
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* define macro function with custom **name**
|
|
38
|
-
* @param name
|
|
39
|
-
* @param callback
|
|
40
|
-
*/
|
|
41
|
-
function macro(name: string, callback: any): any
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* call macro function
|
|
45
|
-
* @param name
|
|
46
|
-
* @param props
|
|
47
|
-
* @param callback
|
|
48
|
-
*/
|
|
49
|
-
function call(name: string, props?: object, callback?: any): any
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* asynchronous template execution
|
|
53
|
-
* @param promise
|
|
54
|
-
* @param callback
|
|
55
|
-
*/
|
|
56
|
-
function async(promise: Promise<any>, callback?: any): any
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* asynchronous template execution
|
|
60
|
-
* @param callback
|
|
61
|
-
*/
|
|
62
|
-
function fn(callback: Function): any
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
*
|
|
66
|
-
* @param {string} tag
|
|
67
|
-
* @param {object} attrs
|
|
68
|
-
* @param {function} content
|
|
69
|
-
*/
|
|
70
|
-
function el(tag: string, attrs?: object, content?: any): any
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* buffer output
|
|
74
|
-
* @param args
|
|
75
|
-
*/
|
|
76
|
-
function echo(...args: any[]): any
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* append rendered template from file
|
|
80
|
-
* @param path
|
|
81
|
-
* @param data
|
|
82
|
-
* @param cx
|
|
83
|
-
*/
|
|
84
|
-
function include(path: string, data?: object, cx?: boolean): any
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
*
|
|
88
|
-
* @param value
|
|
89
|
-
* @param callback
|
|
90
|
-
*/
|
|
91
|
-
function each(value: any, callback: Function): any
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* define block with custom **name** and callback
|
|
95
|
-
* @param {string} name
|
|
96
|
-
* @param {object} [props]
|
|
97
|
-
*/
|
|
98
|
-
function ui(name: string, props?: object): any
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export = global
|