@kosatyi/ejs 0.0.23 → 0.0.25

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.js CHANGED
@@ -43,7 +43,10 @@
43
43
  return typeof v === 'boolean';
44
44
  };
45
45
 
46
- var isNode = new Function('try {return this===global;}catch(e){return false;}');
46
+ var isNodeEnv = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]';
47
+ var isNode = function isNode() {
48
+ return isNodeEnv;
49
+ };
47
50
  var symbolEntities = {
48
51
  "'": "'",
49
52
  '\\': '\\',
@@ -88,6 +91,13 @@
88
91
  });
89
92
  return [data, prop];
90
93
  };
94
+ var ext = function ext(path, defaults) {
95
+ var ext = path.split('.').pop();
96
+ if (ext !== defaults) {
97
+ path = [path, defaults].join('.');
98
+ }
99
+ return path;
100
+ };
91
101
  var extend = function extend() {
92
102
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
93
103
  args[_key] = arguments[_key];
@@ -175,22 +185,22 @@
175
185
  var tags = [{
176
186
  symbol: '-',
177
187
  format: function format(value) {
178
- return "'+\n".concat(this.SAFE, "(").concat(value, ",1)+\n'");
188
+ return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, ",1))\n").concat(this.BUFFER, "('");
179
189
  }
180
190
  }, {
181
191
  symbol: '=',
182
192
  format: function format(value) {
183
- return "'+\n".concat(this.SAFE, "(").concat(value, ")+\n'");
193
+ return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, "))\n").concat(this.BUFFER, "('");
184
194
  }
185
195
  }, {
186
196
  symbol: '#',
187
197
  format: function format(value) {
188
- return "'+\n/**".concat(value, "**/+\n'");
198
+ return "')\n/**".concat(value, "**/\n").concat(this.BUFFER, "('");
189
199
  }
190
200
  }, {
191
201
  symbol: '',
192
202
  format: function format(value) {
193
- return "')\n".concat(value, "\n").concat(this.BUFFER, "('");
203
+ return "')\n".concat(value.trim(), "\n").concat(this.BUFFER, "('");
194
204
  }
195
205
  }];
196
206
  var match = function match(regex, text, callback) {
@@ -204,13 +214,7 @@
204
214
  return match;
205
215
  });
206
216
  };
207
- /**
208
- *
209
- * @param {object} config
210
- * @return {function(*, *): Function}
211
- * @constructor
212
- */
213
- var Compiler = function Compiler(config) {
217
+ var configureCompiler = function configureCompiler(ejs, config) {
214
218
  var withObject = config.withObject;
215
219
  var token = config.token;
216
220
  var vars = config.vars;
@@ -228,11 +232,7 @@
228
232
  var regex = new RegExp(matches.join('|').concat('|$'), 'g');
229
233
  var slurpStart = new RegExp([slurp.match, slurp.start].join(''), 'gm');
230
234
  var slurpEnd = new RegExp([slurp.end, slurp.match].join(''), 'gm');
231
- /**
232
- * @type function
233
- * @name Compile
234
- */
235
- return function (content, path) {
235
+ return function compiler(content, path) {
236
236
  var SCOPE = vars.SCOPE,
237
237
  SAFE = vars.SAFE,
238
238
  BUFFER = vars.BUFFER;
@@ -265,24 +265,34 @@
265
265
  };
266
266
  };
267
267
 
268
- var Wrapper = function Wrapper(config) {
268
+ var configureWrapper = function configureWrapper(config) {
269
269
  var name = config["export"];
270
- return function (list) {
271
- var out = '(function(o){\n';
270
+ var useStrict = config.withObject !== true;
271
+ return function Wrapper(list) {
272
+ var out = '';
273
+ out += '(function(global,factory){';
274
+ out += 'typeof exports === "object" && typeof module !== "undefined" ?';
275
+ out += 'module.exports = factory():';
276
+ out += 'typeof define === "function" && define.amd ? define(factory):';
277
+ out += '(global = typeof globalThis !== "undefined" ? globalThis:';
278
+ out += 'global || self,global["' + name + '"] = factory())';
279
+ out += '})(this,(function(){';
280
+ if (useStrict) out += "'use strict';\n";
281
+ out += 'var list = {};\n';
272
282
  list.forEach(function (item) {
273
- out += 'o[' + JSON.stringify(item.name) + ']=' + String(item.content) + '\n';
283
+ out += 'list[' + JSON.stringify(item.name) + ']=' + String(item.content) + ';\n';
274
284
  });
275
- out += '})(window["' + name + '"] = window["' + name + '"] || {});\n';
285
+ out += 'return list;}));\n';
276
286
  return out;
277
287
  };
278
288
  };
279
289
 
280
- var HttpRequest = function HttpRequest(template) {
281
- return window.fetch(template).then(function (response) {
290
+ var httpRequest = function httpRequest(template) {
291
+ return fetch(template).then(function (response) {
282
292
  return response.text();
283
293
  });
284
294
  };
285
- var FileSystem = function FileSystem(template) {
295
+ var fileSystem = function fileSystem(template) {
286
296
  return new Promise(function (resolve, reject) {
287
297
  path.readFile(template, function (error, data) {
288
298
  if (error) {
@@ -293,7 +303,7 @@
293
303
  });
294
304
  });
295
305
  };
296
- var Watcher = function Watcher(path$1, cache) {
306
+ var enableWatcher = function enableWatcher(path$1, cache) {
297
307
  return path.watch('.', {
298
308
  cwd: path$1
299
309
  }).on('change', function (name) {
@@ -302,10 +312,11 @@
302
312
  console.log('watcher error: ' + error);
303
313
  });
304
314
  };
305
- var Template = function Template(config, cache, compile) {
315
+ var configureTemplate = function configureTemplate(ejs, config) {
306
316
  var path = config.path;
307
- config.token || {};
308
- var resolver = isFunction(config.resolver) ? config.resolver : isNode() ? FileSystem : HttpRequest;
317
+ var cache = ejs.cache,
318
+ compile = ejs.compile;
319
+ var resolver = isFunction(config.resolver) ? config.resolver : isNode() ? fileSystem : httpRequest;
309
320
  var normalize = function normalize(template) {
310
321
  template = [path, template].join('/');
311
322
  template = template.replace(/\/\//g, '/');
@@ -318,19 +329,19 @@
318
329
  cache.set(template, content);
319
330
  return content;
320
331
  };
321
- var get = function get(template) {
322
- if (cache.exist(template)) {
323
- return cache.resolve(template);
332
+ var template = function template(_template) {
333
+ if (cache.exist(_template)) {
334
+ return cache.resolve(_template);
324
335
  }
325
- var content = resolve(template).then(function (content) {
326
- return result(compile(content, template), template);
336
+ var content = resolve(_template).then(function (content) {
337
+ return result(compile(content, _template), _template);
327
338
  });
328
- return result(content, template);
339
+ return result(content, _template);
329
340
  };
330
341
  if (config.watch && isNode()) {
331
- Watcher(path, cache);
342
+ enableWatcher(path, cache);
332
343
  }
333
- return get;
344
+ return template;
334
345
  };
335
346
 
336
347
  var resolve = function resolve(list) {
@@ -338,11 +349,7 @@
338
349
  return list.join('');
339
350
  });
340
351
  };
341
- /**
342
- *
343
- * @return {function}
344
- */
345
- var Buffer = function Buffer() {
352
+ var createBuffer = function createBuffer() {
346
353
  var store = [],
347
354
  array = [];
348
355
  function buffer(value) {
@@ -369,7 +376,7 @@
369
376
  return buffer;
370
377
  };
371
378
 
372
- var configure = function configure(config, methods) {
379
+ var configureScope = function configureScope(ejs, config) {
373
380
  var _config$vars = config.vars,
374
381
  EXTEND = _config$vars.EXTEND,
375
382
  LAYOUT = _config$vars.LAYOUT,
@@ -397,7 +404,7 @@
397
404
  });
398
405
  };
399
406
  Scope.property(BUFFER, {
400
- value: Buffer(),
407
+ value: createBuffer(),
401
408
  writable: false,
402
409
  configurable: false,
403
410
  enumerable: false
@@ -569,17 +576,17 @@
569
576
  }
570
577
  each(object, callback);
571
578
  });
572
- Scope.helpers(methods);
573
579
  return Scope;
574
580
  };
575
581
 
576
- function Cache(config) {
582
+ var global = typeof globalThis !== 'undefined' ? globalThis : window || self;
583
+ function configureCache(config) {
577
584
  var namespace = config["export"];
578
585
  var list = {};
579
586
  var cache = {
580
587
  preload: function preload() {
581
588
  if (isNode() === false) {
582
- this.load(window[namespace]);
589
+ this.load(global[namespace]);
583
590
  }
584
591
  return this;
585
592
  },
@@ -607,53 +614,40 @@
607
614
  return cache.preload();
608
615
  }
609
616
 
610
- function init(options) {
611
- /**
612
- * @type {Object}
613
- */
617
+ function create(options) {
614
618
  var config = {};
615
- var _helpers = {};
616
- var ext = function ext(path, defaults) {
617
- var ext = path.split('.').pop();
618
- if (ext !== defaults) {
619
- path = [path, defaults].join('.');
620
- }
621
- return path;
622
- };
623
- var view = {
619
+ var ejs = {
624
620
  safeValue: safeValue,
625
621
  element: element,
626
622
  output: function output(path, scope) {
627
- return view.template(path).then(function (template) {
623
+ return ejs.template(path).then(function (template) {
628
624
  return template.call(scope, scope, scope.getBuffer(), safeValue);
629
625
  });
630
626
  },
631
627
  render: function render(name, data) {
632
628
  var filepath = ext(name, config.extension);
633
- var scope = new view.scope(data);
634
- return view.output(filepath, scope).then(function (content) {
629
+ var scope = new ejs.scope(data);
630
+ return ejs.output(filepath, scope).then(function (content) {
635
631
  if (scope.getExtend()) {
636
632
  scope.setExtend(false);
637
633
  var layout = scope.getLayout();
638
634
  var _data = scope.clone();
639
- return view.render(layout, _data);
635
+ return ejs.render(layout, _data);
640
636
  }
641
637
  return content;
642
638
  });
643
639
  },
644
640
  require: function require(name) {
645
641
  var filepath = ext(name, config.extension);
646
- var scope = new view.scope({});
647
- return view.output(filepath, scope).then(function () {
642
+ var scope = new ejs.scope({});
643
+ return ejs.output(filepath, scope).then(function () {
648
644
  return scope.getMacro();
649
645
  });
650
646
  },
651
647
  helpers: function helpers(methods) {
652
- methods = methods || {};
653
- extend(_helpers, methods);
654
- view.scope.helpers(methods);
648
+ ejs.scope.helpers(methods);
655
649
  },
656
- configure: function configure$1(options) {
650
+ configure: function configure(options) {
657
651
  config["export"] = typeProp(isString, defaults["export"], options["export"]);
658
652
  config.path = typeProp(isString, defaults.path, options.path);
659
653
  config.resolver = typeProp(isFunction, defaults.resolver, options.resolver);
@@ -661,12 +655,12 @@
661
655
  config.withObject = typeProp(isBoolean, defaults.withObject, options.withObject);
662
656
  config.token = extend({}, defaults.token, options.token);
663
657
  config.vars = extend({}, defaults.vars, options.vars);
664
- view.scope = configure(config, _helpers);
665
- view.compile = Compiler(config);
666
- view.wrapper = Wrapper(config);
667
- view.cache = Cache(config);
668
- view.template = Template(config, view.cache, view.compile);
669
- return view;
658
+ ejs.scope = configureScope(ejs, config);
659
+ ejs.compile = configureCompiler(ejs, config);
660
+ ejs.wrapper = configureWrapper(ejs);
661
+ ejs.cache = configureCache(ejs);
662
+ ejs.template = configureTemplate(ejs, config);
663
+ return ejs;
670
664
  },
671
665
  __express: function __express(name, options, callback) {
672
666
  if (isFunction(options)) {
@@ -681,33 +675,28 @@
681
675
  var filename = path.relative(viewPath, name);
682
676
  viewOptions.path = viewPath;
683
677
  viewOptions.cache = viewCache;
684
- view.configure(viewOptions);
685
- return view.render(filename, options).then(function (content) {
678
+ ejs.configure(viewOptions);
679
+ return ejs.render(filename, options).then(function (content) {
686
680
  callback(null, content);
687
681
  })["catch"](function (error) {
688
682
  callback(error);
689
683
  });
690
684
  }
691
685
  };
692
- /**
693
- *
694
- */
695
- view.configure(options || {});
696
- /**
697
- *
698
- */
699
- view.helpers({
686
+ ejs.configure(options || {});
687
+ ejs.helpers({
700
688
  require: function require(name) {
701
- return view.require(name, this);
689
+ return ejs.require(name, this);
702
690
  },
703
691
  render: function render(name, data) {
704
- return view.render(name, data);
692
+ return ejs.render(name, data);
705
693
  }
706
694
  });
707
- return view;
695
+ return ejs;
708
696
  }
709
- var index = init();
697
+ var instance = create();
698
+ instance.create = create;
710
699
 
711
- return index;
700
+ return instance;
712
701
 
713
702
  }));
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:"ejs",withObject:!0,vars:{SCOPE:"ejs",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",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)y(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}))},w=function(n,t,e){return Promise.resolve(n).then(t.bind(e))},y=function(n,t){return n&&n.hasOwnProperty(t)},x=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],j=" ",E='"',O="/",k="<",F=">";function B(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),[E,l(n),E].join("")].join("=")})).join(j);return r.push([k,n,j,i,F].join("")),e&&r.push(e instanceof Array?e.join(""):e),o&&r.push([k,O,n,F].join("")),r.join("")}var $=[{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,"('")}}],S=function(n){var t=n.withObject,e=n.token,r=n.vars,o=[],i=[],c={match:"[ \\t]*",start:[e.start,"_"],end:["_",e.end]};$.forEach((function(n){o.push(e.start.concat(n.symbol).concat(e.regex).concat(e.end)),i.push(n.format.bind(r))}));var a=new RegExp(o.join("|").concat("|$"),"g"),f=new RegExp([c.match,c.start].join(""),"gm"),s=new RegExp([c.end,c.match].join(""),"gm");return function(n,e){var o=r.SCOPE,l=r.SAFE,p=r.BUFFER;n=(n=n.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")).replace(f,c.start).replace(s,c.end);var v="".concat(p,"('");!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){v+=(""+n.slice(e,r)).replace(h,(function(n){return"\\"+u[n]})),t.forEach((function(n,t){n&&(v+=i[t](n))}))})),v="try{".concat(v+="');","}catch(e){console.info(e)}"),t&&(v="with(".concat(o,"){").concat(v,"}")),v="".concat(p,".start();").concat(v,"return ").concat(p,".end();"),v+="\n//# sourceURL=".concat(e);var d=null;try{(d=new Function(o,p,l,v)).source="(function(".concat(o,",").concat(p,",").concat(l,"){\n").concat(v,"\n})")}catch(n){throw n.filename=e,n.source=v,n}return d}},A=function(n){return window.fetch(n).then((function(n){return n.text()}))},R=function(t){return new Promise((function(e,r){n.readFile(t,(function(n,t){n?r(n):e(t.toString())}))}))},L=function(t,e){return n.watch(".",{cwd:t}).on("change",(function(n){e.remove(n)})).on("error",(function(n){console.log("watcher error: "+n)}))},M=function(n,t,e){var o=n.path;n.token;var i=r(n.resolver)?n.resolver:c()?R:A,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()&&L(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)}},P=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(),P(e)},e.error=function(n){throw n},e.end=function(){return P(t)},e};var C,T,q,_,N,D=(T={},q={},_=function(n,t){var e=n.split(".").pop();return e!==t&&(n=[n,t].join(".")),n},N={safeValue:p,element:B,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,T.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,T.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 T.export=e(o,t.export,n.export),T.path=e(o,t.path,n.path),T.resolver=e(r,t.resolver,n.resolver),T.extension=e(o,t.extension,n.extension),T.withObject=e(i,t.withObject,n.withObject),T.token=d({},t.token,n.token),T.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 s.helpers=function(n){d(s.prototype,n)},s.property=function(n,t){Object.defineProperty(s.prototype,n,t)},s.method=function(n,t){Object.defineProperty(s.prototype,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 y(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()&&y(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(w(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(w(n,(function(n){return this.fn(t)(n)}),this))})),s.method("el",(function(n,t,e){r(e)&&(e=this.fn(e)()),this.echo(w(e,(function(e){return B(n,t,e)}),this))})),s.method("each",(function(n,t){o(n)&&(n=this.get(n,[])),g(n,t)})),s.helpers(t),s}(T,q),N.compile=S(T),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'}}(T),N.cache=function(n){var t=n.export,e={};return{preload:function(){return!1===c()&&this.load(window[t]),this},exist:function(n){return y(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()}(T),N.template=M(T,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(C||{}),N.helpers({require:function(n){return N.require(n,this)},render:function(n,t){return N.render(n,t)}}),N);return D}));
1
+ !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).ejs=n()}(this,(function(){"use strict";var t={},n={export:"ejs.precompiled",cache:!0,path:"views",resolver:null,extension:"ejs",withObject:!0,vars:{SCOPE:"ejs",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},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="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),u=function(){return c},a={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},f={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},s=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},h=s(f),l=s(a),p=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(""+t).replace(h,(function(t){return f[t]}))},d=function(t,n,e){return null==(e=t)?"":n?p(e):e},v=function(t,n){var e=t,r=n.split("."),o=r.pop();return r.forEach((function(t){e=e[t]=e[t]||{}})),[e,o]},m=function(t,n){var e=t.split(".").pop();return e!==n&&(t=[t,n].join(".")),t},g=function(){for(var t=arguments.length,n=new Array(t),e=0;e<t;e++)n[e]=arguments[e];var r=n.shift();return n.filter((function(t){return t})).reduce((function(t,n){return Object.assign(t,n)}),r)},b=function(){},y=function(t,n){var e;for(e in t)j(t,e)&&n(t[e],e,t)},w=function(t,n){return function(t,n,e){var r=t instanceof Array,o=r?[]:{};return y(t,(function(t,e,i){var c=n(t,e,i);void 0!==c&&(r?o.push(c):o[e]=c)})),o}(t,(function(t,e){if(-1===n.indexOf(e))return t}))},x=function(t,n,e){return Promise.resolve(t).then(n.bind(e))},j=function(t,n){return t&&t.hasOwnProperty(n)},E=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],F=" ",O='"',B="/",R="<",k=">";function $(t,n,e){var r=[],o=-1===E.indexOf(t),i=function(t,n,e){var r=[];return y(t,(function(t,e,o){var i=n(t,e,o);void 0!==i&&r.push(i)})),r}(n,(function(t,n){if(null!=t)return[p(n),[O,p(t),O].join("")].join("=")})).join(F);return r.push([R,t,F,i,k].join("")),e&&r.push(e instanceof Array?e.join(""):e),o&&r.push([R,B,t,k].join("")),r.join("")}var S=[{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,"('")}}],U=function(t,n){var e=n.withObject,r=n.token,o=n.vars,i=[],c=[],u={match:"[ \\t]*",start:[r.start,"_"],end:["_",r.end]};S.forEach((function(t){i.push(r.start.concat(t.symbol).concat(r.regex).concat(r.end)),c.push(t.format.bind(o))}));var f=new RegExp(i.join("|").concat("|$"),"g"),s=new RegExp([u.match,u.start].join(""),"gm"),h=new RegExp([u.end,u.match].join(""),"gm");return function(t,n){var r=o.SCOPE,i=o.SAFE,p=o.BUFFER;t=(t=t.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")).replace(s,u.start).replace(h,u.end);var d="".concat(p,"('");!function(t,n,e){var r=0;n.replace(t,(function(){var t=[].slice.call(arguments,0,-1),n=t.pop(),o=t.shift();return e(t,r,n),r=n+o.length,o}))}(f,t,(function(n,e,r){d+=(""+t.slice(e,r)).replace(l,(function(t){return"\\"+a[t]})),n.forEach((function(t,n){t&&(d+=c[n](t))}))})),d="try{".concat(d+="');","}catch(e){console.info(e)}"),e&&(d="with(".concat(r,"){").concat(d,"}")),d="".concat(p,".start();").concat(d,"return ").concat(p,".end();"),d+="\n//# sourceURL=".concat(n);var v=null;try{(v=new Function(r,p,i,d)).source="(function(".concat(r,",").concat(p,",").concat(i,"){\n").concat(d,"\n})")}catch(t){throw t.filename=n,t.source=d,t}return v}},A=function(t){return fetch(t).then((function(t){return t.text()}))},T=function(n){return new Promise((function(e,r){t.readFile(n,(function(t,n){t?r(t):e(n.toString())}))}))},L=function(n,e){return t.watch(".",{cwd:n}).on("change",(function(t){e.remove(t)})).on("error",(function(t){console.log("watcher error: "+t)}))},M=function(t,n){var e=n.path,o=t.cache,i=t.compile,c=r(n.resolver)?n.resolver:u()?T:A,a=function(t){return c(function(t){return(t=[e,t].join("/")).replace(/\/\//g,"/")}(t))},f=function(t,n){return o.set(n,t),t};return n.watch&&u()&&L(e,o),function(t){if(o.exist(t))return o.resolve(t);var n=a(t).then((function(n){return f(i(n,t),t)}));return f(n,t)}},P=function(t){return Promise.all(t).then((function(t){return t.join("")}))},C=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(),P(e)},e.error=function(t){throw t},e.end=function(){return P(n)},e},q="undefined"!=typeof globalThis?globalThis:window||self;function _(c){var a={},f={safeValue:d,element:$,output:function(t,n){return f.template(t).then((function(t){return t.call(n,n,n.getBuffer(),d)}))},render:function(t,n){var e=m(t,a.extension),r=new f.scope(n);return f.output(e,r).then((function(t){if(r.getExtend()){r.setExtend(!1);var n=r.getLayout(),e=r.clone();return f.render(n,e)}return t}))},require:function(t){var n=m(t,a.extension),e=new f.scope({});return f.output(n,e).then((function(){return e.getMacro()}))},helpers:function(t){f.scope.helpers(t)},configure:function(t){return a.export=e(o,n.export,t.export),a.path=e(o,n.path,t.path),a.resolver=e(r,n.resolver,t.resolver),a.extension=e(o,n.extension,t.extension),a.withObject=e(i,n.withObject,t.withObject),a.token=g({},n.token,t.token),a.vars=g({},n.vars,t.vars),f.scope=function(t,n){var e=n.vars,i=e.EXTEND,c=e.LAYOUT,u=e.BLOCKS,a=e.BUFFER,f=e.MACRO;function s(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),g(this,t)}return s.helpers=function(t){g(s.prototype,t)},s.property=function(t,n){Object.defineProperty(s.prototype,t,n)},s.method=function(t,n){Object.defineProperty(s.prototype,t,{value:n,writable:!1,configurable:!1,enumerable:!1})},s.property(a,{value:C(),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(t){this[i]=t})),s.method("getExtend",(function(){return this[i]})),s.method("setLayout",(function(t){this[c]=t})),s.method("getLayout",(function(){return this[c]})),s.method("clone",(function(t){var n=[c,i,a];return!0===t&&n.push(u),w(this,n)})),s.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),s.method("echo",(function(){var t=this.getBuffer();[].slice.call(arguments).forEach((function(n){t(n)}))})),s.method("fn",(function(t){var n=this.getBuffer(),e=this;return function(){return n.backup(),r(t)&&t.apply(e,arguments),n.restore()}})),s.method("get",(function(t,n){var e=v(this,t),r=e.shift(),o=e.pop();return j(r,o)?r[o]:n})),s.method("set",(function(t,n){var e=v(this,t),r=e.shift(),o=e.pop();return this.getExtend()&&j(r,o)?r[o]:r[o]=n})),s.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))}})),s.method("call",(function(t){var n=this.getMacro()[t],e=[].slice.call(arguments,1);if(r(n))return n.apply(n,e)})),s.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()))}:b}()))}})),s.method("include",(function(t,n,e){var r=!1===e?{}:this.clone(!0),o=g(r,n||{}),i=this.render(t,o);this.echo(i)})),s.method("use",(function(t,n){var e=this.require(t);this.echo(x(e,(function(t){var e=this.getMacro();y(t,(function(t,r){e[[n,r].join(".")]=t}))}),this))})),s.method("async",(function(t,n){this.echo(x(t,(function(t){return this.fn(n)(t)}),this))})),s.method("el",(function(t,n,e){r(e)&&(e=this.fn(e)()),this.echo(x(e,(function(e){return $(t,n,e)}),this))})),s.method("each",(function(t,n){o(t)&&(t=this.get(t,[])),y(t,n)})),s}(0,a),f.compile=U(0,a),f.wrapper=function(t){var n=t.export,e=!0!==t.withObject;return function(t){var r="";return r+="(function(global,factory){",r+='typeof exports === "object" && typeof module !== "undefined" ?',r+="module.exports = factory():",r+='typeof define === "function" && define.amd ? define(factory):',r+='(global = typeof globalThis !== "undefined" ? globalThis:',r+='global || self,global["'+n+'"] = factory())',r+="})(this,(function(){",e&&(r+="'use strict';\n"),r+="var list = {};\n",t.forEach((function(t){r+="list["+JSON.stringify(t.name)+"]="+String(t.content)+";\n"})),r+="return list;}));\n"}}(f),f.cache=function(t){var n=t.export,e={};return{preload:function(){return!1===u()&&this.load(q[n]),this},exist:function(t){return j(e,t)},get:function(t){return e[t]},remove:function(t){delete e[t]},resolve:function(t){return Promise.resolve(this.get(t))},set:function(t,n){return e[t]=n,this},load:function(t){return g(e,t),this}}.preload()}(f),f.template=M(f,a),f},__express:function(c,u,a){r(u)&&(a=u,u={});var s=g({},(u=u||{}).settings),h=e(o,s.views,n.path),l=e(i,s["view cache"],n.cache),p=g({},s["view options"]),d=t.relative(h,c);return p.path=h,p.cache=l,f.configure(p),f.render(d,u).then((function(t){a(null,t)})).catch((function(t){a(t)}))}};return f.configure(c||{}),f.helpers({require:function(t){return f.require(t,this)},render:function(t,n){return f.render(t,n)}}),f}var N=_();return N.create=_,N}));