@kosatyi/ejs 0.0.73 → 0.0.75

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.
@@ -5,6 +5,9 @@ var typeProp = function typeProp() {
5
5
  var callback = args.shift();
6
6
  return args.filter(callback).pop();
7
7
  };
8
+ var isArray = function isArray(v) {
9
+ return Array.isArray(v);
10
+ };
8
11
  var isFunction = function isFunction(v) {
9
12
  return typeof v === 'function';
10
13
  };
@@ -166,6 +169,7 @@ defaults.resolver = function (path, template) {
166
169
  defaults.extension = 'ejs';
167
170
  defaults.rmWhitespace = true;
168
171
  defaults.withObject = true;
172
+ defaults.globalHelpers = [];
169
173
  defaults.vars = {
170
174
  SCOPE: 'ejs',
171
175
  COMPONENT: 'ui',
@@ -192,7 +196,8 @@ var configSchema = function configSchema(config, options) {
192
196
  rmWhitespace: typeProp(isBoolean, defaults.rmWhitespace, config.rmWhitespace, options.rmWhitespace),
193
197
  cache: typeProp(isBoolean, defaults.cache, config.cache, options.cache),
194
198
  token: extend({}, defaults.token, config.token, options.token),
195
- vars: extend({}, defaults.vars, config.vars, options.vars)
199
+ vars: extend({}, defaults.vars, config.vars, options.vars),
200
+ globalHelpers: typeProp(isArray, defaults.globalHelpers, config.globalHelpers, options.globalHelpers)
196
201
  });
197
202
  };
198
203
 
@@ -280,6 +285,7 @@ function Compiler(config) {
280
285
  compiler.rmWhitespace = config.rmWhitespace;
281
286
  compiler.token = config.token;
282
287
  compiler.vars = config.vars;
288
+ compiler.globalHelpers = config.globalHelpers;
283
289
  compiler.matches = [];
284
290
  compiler.formats = [];
285
291
  compiler.slurp = {
@@ -301,6 +307,7 @@ function Compiler(config) {
301
307
  SAFE = _compiler$vars.SAFE,
302
308
  BUFFER = _compiler$vars.BUFFER,
303
309
  COMPONENT = _compiler$vars.COMPONENT;
310
+ var GLOBALS = compiler.globalHelpers;
304
311
  if (compiler.rmWhitespace) {
305
312
  content = content.replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
306
313
  }
@@ -322,9 +329,10 @@ function Compiler(config) {
322
329
  source = "".concat(BUFFER, ".start();").concat(source, "return ").concat(BUFFER, ".end();");
323
330
  source += "\n//# sourceURL=".concat(path);
324
331
  var result = null;
332
+ var params = [SCOPE, COMPONENT, BUFFER, SAFE].concat(GLOBALS);
325
333
  try {
326
- result = new Function(SCOPE, COMPONENT, BUFFER, SAFE, source);
327
- result.source = "(function(".concat(SCOPE, ",").concat(COMPONENT, ",").concat(BUFFER, ",").concat(SAFE, "){\n").concat(source, "\n})");
334
+ result = Function.apply(null, params.concat(source));
335
+ result.source = "(function(".concat(params.join(','), "){\n").concat(source, "\n})");
328
336
  } catch (e) {
329
337
  e.filename = path;
330
338
  e.source = source;
@@ -761,9 +769,13 @@ function EJS(options) {
761
769
  var compiler = new Compiler(config);
762
770
  var cache = new Cache();
763
771
  var template = new Template(config, cache, compiler);
764
- var output = function output(path, scope) {
772
+ var output = function output(path, context) {
773
+ var params = [context, context.getComponent(), context.getBuffer(), safeValue];
774
+ config.globalHelpers.forEach(function (name) {
775
+ if (isFunction(context[name])) params.push(context[name].bind(context));
776
+ });
765
777
  return template.get(path).then(function (callback) {
766
- return callback.call(scope, scope, scope.getComponent(), scope.getBuffer(), safeValue);
778
+ return callback.apply(context, params);
767
779
  });
768
780
  };
769
781
  var require = function require(name) {
package/dist/cjs/index.js CHANGED
@@ -8,6 +8,9 @@ var typeProp = function typeProp() {
8
8
  var callback = args.shift();
9
9
  return args.filter(callback).pop();
10
10
  };
11
+ var isArray = function isArray(v) {
12
+ return Array.isArray(v);
13
+ };
11
14
  var isFunction = function isFunction(v) {
12
15
  return typeof v === 'function';
13
16
  };
@@ -169,6 +172,7 @@ defaults.resolver = function (path, template) {
169
172
  defaults.extension = 'ejs';
170
173
  defaults.rmWhitespace = true;
171
174
  defaults.withObject = true;
175
+ defaults.globalHelpers = [];
172
176
  defaults.vars = {
173
177
  SCOPE: 'ejs',
174
178
  COMPONENT: 'ui',
@@ -195,7 +199,8 @@ var configSchema = function configSchema(config, options) {
195
199
  rmWhitespace: typeProp(isBoolean, defaults.rmWhitespace, config.rmWhitespace, options.rmWhitespace),
196
200
  cache: typeProp(isBoolean, defaults.cache, config.cache, options.cache),
197
201
  token: extend({}, defaults.token, config.token, options.token),
198
- vars: extend({}, defaults.vars, config.vars, options.vars)
202
+ vars: extend({}, defaults.vars, config.vars, options.vars),
203
+ globalHelpers: typeProp(isArray, defaults.globalHelpers, config.globalHelpers, options.globalHelpers)
199
204
  });
200
205
  };
201
206
 
@@ -283,6 +288,7 @@ function Compiler(config) {
283
288
  compiler.rmWhitespace = config.rmWhitespace;
284
289
  compiler.token = config.token;
285
290
  compiler.vars = config.vars;
291
+ compiler.globalHelpers = config.globalHelpers;
286
292
  compiler.matches = [];
287
293
  compiler.formats = [];
288
294
  compiler.slurp = {
@@ -304,6 +310,7 @@ function Compiler(config) {
304
310
  SAFE = _compiler$vars.SAFE,
305
311
  BUFFER = _compiler$vars.BUFFER,
306
312
  COMPONENT = _compiler$vars.COMPONENT;
313
+ var GLOBALS = compiler.globalHelpers;
307
314
  if (compiler.rmWhitespace) {
308
315
  content = content.replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
309
316
  }
@@ -325,9 +332,10 @@ function Compiler(config) {
325
332
  source = "".concat(BUFFER, ".start();").concat(source, "return ").concat(BUFFER, ".end();");
326
333
  source += "\n//# sourceURL=".concat(path);
327
334
  var result = null;
335
+ var params = [SCOPE, COMPONENT, BUFFER, SAFE].concat(GLOBALS);
328
336
  try {
329
- result = new Function(SCOPE, COMPONENT, BUFFER, SAFE, source);
330
- result.source = "(function(".concat(SCOPE, ",").concat(COMPONENT, ",").concat(BUFFER, ",").concat(SAFE, "){\n").concat(source, "\n})");
337
+ result = Function.apply(null, params.concat(source));
338
+ result.source = "(function(".concat(params.join(','), "){\n").concat(source, "\n})");
331
339
  } catch (e) {
332
340
  e.filename = path;
333
341
  e.source = source;
@@ -764,9 +772,13 @@ function EJS(options) {
764
772
  var compiler = new Compiler(config);
765
773
  var cache = new Cache();
766
774
  var template = new Template(config, cache, compiler);
767
- var output = function output(path, scope) {
775
+ var output = function output(path, context) {
776
+ var params = [context, context.getComponent(), context.getBuffer(), safeValue];
777
+ config.globalHelpers.forEach(function (name) {
778
+ if (isFunction(context[name])) params.push(context[name].bind(context));
779
+ });
768
780
  return template.get(path).then(function (callback) {
769
- return callback.call(scope, scope, scope.getComponent(), scope.getBuffer(), safeValue);
781
+ return callback.apply(context, params);
770
782
  });
771
783
  };
772
784
  var require = function require(name) {
@@ -3,6 +3,7 @@ const typeProp = function () {
3
3
  const callback = args.shift();
4
4
  return args.filter(callback).pop()
5
5
  };
6
+ const isArray = (v) => Array.isArray(v);
6
7
  const isFunction = (v) => typeof v === 'function';
7
8
  const isString = (v) => typeof v === 'string';
8
9
  const isBoolean = (v) => typeof v === 'boolean';
@@ -178,6 +179,7 @@ defaults.resolver = function (path, template) {
178
179
  defaults.extension = 'ejs';
179
180
  defaults.rmWhitespace = true;
180
181
  defaults.withObject = true;
182
+ defaults.globalHelpers = [];
181
183
  defaults.vars = {
182
184
  SCOPE: 'ejs',
183
185
  COMPONENT: 'ui',
@@ -230,6 +232,12 @@ const configSchema = (config, options) => {
230
232
  cache: typeProp(isBoolean, defaults.cache, config.cache, options.cache),
231
233
  token: extend({}, defaults.token, config.token, options.token),
232
234
  vars: extend({}, defaults.vars, config.vars, options.vars),
235
+ globalHelpers: typeProp(
236
+ isArray,
237
+ defaults.globalHelpers,
238
+ config.globalHelpers,
239
+ options.globalHelpers
240
+ ),
233
241
  });
234
242
  };
235
243
 
@@ -327,6 +335,7 @@ function Compiler(config) {
327
335
  compiler.rmWhitespace = config.rmWhitespace;
328
336
  compiler.token = config.token;
329
337
  compiler.vars = config.vars;
338
+ compiler.globalHelpers = config.globalHelpers;
330
339
  compiler.matches = [];
331
340
  compiler.formats = [];
332
341
  compiler.slurp = {
@@ -359,6 +368,7 @@ function Compiler(config) {
359
368
 
360
369
  this.compile = function (content, path) {
361
370
  const { SCOPE, SAFE, BUFFER, COMPONENT } = compiler.vars;
371
+ const GLOBALS = compiler.globalHelpers;
362
372
  if (compiler.rmWhitespace) {
363
373
  content = content
364
374
  .replace(/[\r\n]+/g, '\n')
@@ -384,9 +394,10 @@ function Compiler(config) {
384
394
  source = `${BUFFER}.start();${source}return ${BUFFER}.end();`;
385
395
  source += `\n//# sourceURL=${path}`;
386
396
  let result = null;
397
+ let params = [SCOPE, COMPONENT, BUFFER, SAFE].concat(GLOBALS);
387
398
  try {
388
- result = new Function(SCOPE, COMPONENT, BUFFER, SAFE, source);
389
- result.source = `(function(${SCOPE},${COMPONENT},${BUFFER},${SAFE}){\n${source}\n})`;
399
+ result = Function.apply(null, params.concat(source));
400
+ result.source = `(function(${params.join(',')}){\n${source}\n})`;
390
401
  } catch (e) {
391
402
  e.filename = path;
392
403
  e.source = source;
@@ -873,15 +884,19 @@ function EJS(options) {
873
884
  const cache = new Cache();
874
885
  const template = new Template(config, cache, compiler);
875
886
 
876
- const output = (path, scope) => {
887
+ const output = (path, context) => {
888
+ const params = [
889
+ context,
890
+ context.getComponent(),
891
+ context.getBuffer(),
892
+ safeValue,
893
+ ];
894
+ config.globalHelpers.forEach((name) => {
895
+ if (isFunction(context[name]))
896
+ params.push(context[name].bind(context));
897
+ });
877
898
  return template.get(path).then(function (callback) {
878
- return callback.call(
879
- scope,
880
- scope,
881
- scope.getComponent(),
882
- scope.getBuffer(),
883
- safeValue
884
- )
899
+ return callback.apply(context, params)
885
900
  })
886
901
  };
887
902
  const require = (name) => {
package/dist/esm/index.js CHANGED
@@ -6,6 +6,7 @@ const typeProp = function () {
6
6
  const callback = args.shift();
7
7
  return args.filter(callback).pop()
8
8
  };
9
+ const isArray = (v) => Array.isArray(v);
9
10
  const isFunction = (v) => typeof v === 'function';
10
11
  const isString = (v) => typeof v === 'string';
11
12
  const isBoolean = (v) => typeof v === 'boolean';
@@ -181,6 +182,7 @@ defaults.resolver = function (path, template) {
181
182
  defaults.extension = 'ejs';
182
183
  defaults.rmWhitespace = true;
183
184
  defaults.withObject = true;
185
+ defaults.globalHelpers = [];
184
186
  defaults.vars = {
185
187
  SCOPE: 'ejs',
186
188
  COMPONENT: 'ui',
@@ -233,6 +235,12 @@ const configSchema = (config, options) => {
233
235
  cache: typeProp(isBoolean, defaults.cache, config.cache, options.cache),
234
236
  token: extend({}, defaults.token, config.token, options.token),
235
237
  vars: extend({}, defaults.vars, config.vars, options.vars),
238
+ globalHelpers: typeProp(
239
+ isArray,
240
+ defaults.globalHelpers,
241
+ config.globalHelpers,
242
+ options.globalHelpers
243
+ ),
236
244
  });
237
245
  };
238
246
 
@@ -330,6 +338,7 @@ function Compiler(config) {
330
338
  compiler.rmWhitespace = config.rmWhitespace;
331
339
  compiler.token = config.token;
332
340
  compiler.vars = config.vars;
341
+ compiler.globalHelpers = config.globalHelpers;
333
342
  compiler.matches = [];
334
343
  compiler.formats = [];
335
344
  compiler.slurp = {
@@ -362,6 +371,7 @@ function Compiler(config) {
362
371
 
363
372
  this.compile = function (content, path) {
364
373
  const { SCOPE, SAFE, BUFFER, COMPONENT } = compiler.vars;
374
+ const GLOBALS = compiler.globalHelpers;
365
375
  if (compiler.rmWhitespace) {
366
376
  content = content
367
377
  .replace(/[\r\n]+/g, '\n')
@@ -387,9 +397,10 @@ function Compiler(config) {
387
397
  source = `${BUFFER}.start();${source}return ${BUFFER}.end();`;
388
398
  source += `\n//# sourceURL=${path}`;
389
399
  let result = null;
400
+ let params = [SCOPE, COMPONENT, BUFFER, SAFE].concat(GLOBALS);
390
401
  try {
391
- result = new Function(SCOPE, COMPONENT, BUFFER, SAFE, source);
392
- result.source = `(function(${SCOPE},${COMPONENT},${BUFFER},${SAFE}){\n${source}\n})`;
402
+ result = Function.apply(null, params.concat(source));
403
+ result.source = `(function(${params.join(',')}){\n${source}\n})`;
393
404
  } catch (e) {
394
405
  e.filename = path;
395
406
  e.source = source;
@@ -876,15 +887,19 @@ function EJS(options) {
876
887
  const cache = new Cache();
877
888
  const template = new Template(config, cache, compiler);
878
889
 
879
- const output = (path, scope) => {
890
+ const output = (path, context) => {
891
+ const params = [
892
+ context,
893
+ context.getComponent(),
894
+ context.getBuffer(),
895
+ safeValue,
896
+ ];
897
+ config.globalHelpers.forEach((name) => {
898
+ if (isFunction(context[name]))
899
+ params.push(context[name].bind(context));
900
+ });
880
901
  return template.get(path).then(function (callback) {
881
- return callback.call(
882
- scope,
883
- scope,
884
- scope.getComponent(),
885
- scope.getBuffer(),
886
- safeValue
887
- )
902
+ return callback.apply(context, params)
888
903
  })
889
904
  };
890
905
  const require = (name) => {
@@ -1,7 +1,7 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
3
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.browser = {}));
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ejs = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
7
  var typeProp = function typeProp() {
@@ -9,6 +9,9 @@
9
9
  var callback = args.shift();
10
10
  return args.filter(callback).pop();
11
11
  };
12
+ var isArray = function isArray(v) {
13
+ return Array.isArray(v);
14
+ };
12
15
  var isFunction = function isFunction(v) {
13
16
  return typeof v === 'function';
14
17
  };
@@ -170,6 +173,7 @@
170
173
  defaults.extension = 'ejs';
171
174
  defaults.rmWhitespace = true;
172
175
  defaults.withObject = true;
176
+ defaults.globalHelpers = [];
173
177
  defaults.vars = {
174
178
  SCOPE: 'ejs',
175
179
  COMPONENT: 'ui',
@@ -196,7 +200,8 @@
196
200
  rmWhitespace: typeProp(isBoolean, defaults.rmWhitespace, config.rmWhitespace, options.rmWhitespace),
197
201
  cache: typeProp(isBoolean, defaults.cache, config.cache, options.cache),
198
202
  token: extend({}, defaults.token, config.token, options.token),
199
- vars: extend({}, defaults.vars, config.vars, options.vars)
203
+ vars: extend({}, defaults.vars, config.vars, options.vars),
204
+ globalHelpers: typeProp(isArray, defaults.globalHelpers, config.globalHelpers, options.globalHelpers)
200
205
  });
201
206
  };
202
207
 
@@ -284,6 +289,7 @@
284
289
  compiler.rmWhitespace = config.rmWhitespace;
285
290
  compiler.token = config.token;
286
291
  compiler.vars = config.vars;
292
+ compiler.globalHelpers = config.globalHelpers;
287
293
  compiler.matches = [];
288
294
  compiler.formats = [];
289
295
  compiler.slurp = {
@@ -305,6 +311,7 @@
305
311
  SAFE = _compiler$vars.SAFE,
306
312
  BUFFER = _compiler$vars.BUFFER,
307
313
  COMPONENT = _compiler$vars.COMPONENT;
314
+ var GLOBALS = compiler.globalHelpers;
308
315
  if (compiler.rmWhitespace) {
309
316
  content = content.replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
310
317
  }
@@ -326,9 +333,10 @@
326
333
  source = "".concat(BUFFER, ".start();").concat(source, "return ").concat(BUFFER, ".end();");
327
334
  source += "\n//# sourceURL=".concat(path);
328
335
  var result = null;
336
+ var params = [SCOPE, COMPONENT, BUFFER, SAFE].concat(GLOBALS);
329
337
  try {
330
- result = new Function(SCOPE, COMPONENT, BUFFER, SAFE, source);
331
- result.source = "(function(".concat(SCOPE, ",").concat(COMPONENT, ",").concat(BUFFER, ",").concat(SAFE, "){\n").concat(source, "\n})");
338
+ result = Function.apply(null, params.concat(source));
339
+ result.source = "(function(".concat(params.join(','), "){\n").concat(source, "\n})");
332
340
  } catch (e) {
333
341
  e.filename = path;
334
342
  e.source = source;
@@ -765,9 +773,13 @@
765
773
  var compiler = new Compiler(config);
766
774
  var cache = new Cache();
767
775
  var template = new Template(config, cache, compiler);
768
- var output = function output(path, scope) {
776
+ var output = function output(path, context) {
777
+ var params = [context, context.getComponent(), context.getBuffer(), safeValue];
778
+ config.globalHelpers.forEach(function (name) {
779
+ if (isFunction(context[name])) params.push(context[name].bind(context));
780
+ });
769
781
  return template.get(path).then(function (callback) {
770
- return callback.call(scope, scope, scope.getComponent(), scope.getBuffer(), safeValue);
782
+ return callback.apply(context, params);
771
783
  });
772
784
  };
773
785
  var require = function require(name) {
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).browser={})}(this,(function(e){"use strict";var n=function(){var e=[].slice.call(arguments),n=e.shift();return e.filter(n).pop()},t=function(e){return"function"==typeof e},r=function(e){return"string"==typeof e},i=function(e){return"boolean"==typeof e},o=function(e){return void 0===e},u="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),c=function(){return u},a={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},l={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},s=function(e){return new RegExp(["[",Object.keys(e).join(""),"]"].join(""),"g")},f=s(l),h=s(a),p=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(f,(function(e){return l[e]}))},b=function(e){return(""+e).replace(h,(function(e){return"\\"+a[e]}))},v=function(e,n){var t=e;return null==t?"":!0===n?p(t):t},g=function(e,n){return Boolean(e instanceof n)},m=function(e,n,r){for(var i=e,o=String(n).split("."),u=o.pop(),c=0;c<o.length;c++){var a=o[c];if(t(i.toJSON)&&(i=i.toJSON()),r&&!1===i.hasOwnProperty(a)){i={};break}i=i[a]=i[a]||{}}return t(i.toJSON)&&(i=i.toJSON()),[i,u]},w=function(e,n){var t=e.split(".").pop();return t!==n&&(e=[e,n].join(".")),e},d=function(e){for(var n=arguments.length,t=new Array(n>1?n-1:0),r=1;r<n;r++)t[r-1]=arguments[r];return t.filter((function(e){return e})).reduce((function(e,n){return Object.assign(e,n)}),e)},y=function(){},x=function(e,n){var t;for(t in e)O(e,t)&&n(e[t],t,e)},E=function(e,n){return function(e,n,t){var r=e instanceof Array,i=r?[]:{};return x(e,(function(e,t,u){var c=n(e,t,u);!1===o(c)&&(r?i.push(c):i[t]=c)})),i}(e,(function(e,t){if(-1===n.indexOf(t))return e}))},j=function(e,n,t){return Promise.resolve(e).then(n.bind(t))},O=function(e,n){return e&&e.hasOwnProperty(n)},k={export:"ejsPrecompiled",cache:!0,chokidar:null,path:"views",resolver:function(e,n){return Promise.resolve(["resolver is not defined",e,n].join(" "))},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]+?)"}},F=function(e,o){d(e,{path:n(r,k.path,e.path,o.path),export:n(r,k.export,e.export,o.export),resolver:n(t,k.resolver,e.resolver,o.resolver),extension:n(r,k.extension,e.extension,o.extension),withObject:n(i,k.withObject,e.withObject,o.withObject),rmWhitespace:n(i,k.rmWhitespace,e.rmWhitespace,o.rmWhitespace),cache:n(i,k.cache,e.cache,o.cache),token:d({},k.token,e.token,o.token),vars:d({},k.vars,e.vars,o.vars)})},S="undefined"!=typeof globalThis?globalThis:window||self;function B(e){if(!1===g(this,B))return new B;var n={enabled:!0,list:{}};this.configure=function(e){n.enabled=e.cache,!1===c()&&this.load(S[e.export])},this.clear=function(){n.list={}},this.load=function(e){return n.enabled&&d(n.list,e||{}),this},this.get=function(e){if(n.enabled)return n.list[e]},this.set=function(e,t){return n.enabled&&(n.list[e]=t),this},this.resolve=function(e){return Promise.resolve(this.get(e))},this.remove=function(e){delete n.list[e]},this.exist=function(e){return O(n.list,e)}}var P=[{symbol:"-",format:function(e){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(e,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(e){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(e,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(e){return"')\n/**".concat(e,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(e){return"')\n".concat(e.trim(),"\n").concat(this.BUFFER,"('")}}];function R(e){if(!1===g(this,R))return new R(e);var n={};this.configure=function(e){n.withObject=e.withObject,n.rmWhitespace=e.rmWhitespace,n.token=e.token,n.vars=e.vars,n.matches=[],n.formats=[],n.slurp={match:"[ \\t]*",start:[n.token.start,"_"],end:["_",n.token.end]},P.forEach((function(e){n.matches.push(n.token.start.concat(e.symbol).concat(n.token.regex).concat(n.token.end)),n.formats.push(e.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(e,t){var r=n.vars,i=r.SCOPE,o=r.SAFE,u=r.BUFFER,c=r.COMPONENT;n.rmWhitespace&&(e=e.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),e=e.replace(n.slurpStart,n.token.start).replace(n.slurpEnd,n.token.end);var a,l,s,f="".concat(u,"('");a=n.regex,l=function(t,r,i){f+=b(e.slice(r,i)),t.forEach((function(e,t){e&&(f+=n.formats[t](e))}))},s=0,e.replace(a,(function(){var e=[].slice.call(arguments,0,-1),n=e.pop(),t=e.shift();return l(e,s,n),s=n+t.length,t})),f="try{".concat(f+="');","}catch(e){console.info(e)}"),n.withObject&&(f="with(".concat(i,"){").concat(f,"}")),f="".concat(u,".start();").concat(f,"return ").concat(u,".end();"),f+="\n//# sourceURL=".concat(t);var h=null;try{(h=new Function(i,c,u,o,f)).source="(function(".concat(i,",").concat(c,",").concat(u,",").concat(o,"){\n").concat(f,"\n})")}catch(e){throw e.filename=t,e.source=f,e}return h},this.configure(e)}function T(e,n,r){if(!1===g(this,T))return new T(e,n,r);if(!1===g(n,B))throw new TypeError("cache is not instance of Cache");if(!1===g(r,R))throw new TypeError("compiler is not instance of Compiler");var i={},o=function(e){return i.resolver(i.path,e)};this.configure=function(e){i.path=e.path,i.cache=e.cache,t(e.resolver)&&(i.resolver=e.resolver)},this.get=function(e){return n.exist(e)?n.resolve(e):o(e).then((function(i){return function(e,t){return n.set(e,t),t}(e,function(e,n){return t(e)?e:r.compile(e,n)}(i,e))}))},this.configure(e)}function $(e,n,t){return(n=function(e){var n=function(e,n){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,n||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(e,"string");return"symbol"==typeof n?n:String(n)}(n))in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var C=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],N=" ",U='"',A="/",M="<",L=">",W=function(e,n,t){var r=[],i=-1===C.indexOf(e),u=function(e,n,t){var r=[];return x(e,(function(e,t,i){var u=n(e,t,i);!1===o(u)&&r.push(u)})),r}(n,(function(e,n){if(null!=e)return[p(n),[U,p(e),U].join("")].join("=")})).join(N);return r.push([M,e,N,u,L].join("")),t&&r.push(t instanceof Array?t.join(""):t),i&&r.push([M,A,e,L].join("")),r.join("")};function J(e){return Promise.all(e||[]).then((function(e){return e.join("")}))}function q(){var e=[],n=[];function t(e){n.push(e)}return t.start=function(){n=[]},t.backup=function(){e.push(n.concat()),n=[]},t.restore=function(){var t=n.concat();return n=e.pop(),J(t)},t.error=function(e){throw e},t.end=function(){return J(n)},t}function D(e){if(!1===g(this,D))return new D(e);this.configure=function(e,n){var i,o=e.vars,u=o.BLOCKS,c=o.MACRO,a=o.EXTEND,l=o.LAYOUT,s=o.BUFFER,f=o.COMPONENT;function h(e){this[u]={},this[c]={},d(this,e||{})}this.create=function(e){return new h(e)},this.helpers=function(e){d(h.prototype,e||{})},h.prototype=d({},n||{}),Object.defineProperties(h.prototype,($(i={},s,{value:q(),writable:!0,configurable:!1,enumerable:!1}),$(i,u,{value:{},writable:!0,configurable:!1,enumerable:!1}),$(i,c,{value:{},writable:!0,configurable:!1,enumerable:!1}),$(i,l,{value:!1,writable:!0,configurable:!1,enumerable:!1}),$(i,a,{value:!1,writable:!0,configurable:!1,enumerable:!1}),$(i,"getMacro",{value:function(){return this[c]},writable:!1,configurable:!1,enumerable:!1}),$(i,"getBuffer",{value:function(){return this[s]},writable:!1,configurable:!1,enumerable:!1}),$(i,"getComponent",{value:function(){var e=this;return f in e?function(){return e[f].apply(e,arguments)}:function(){console.log("%s function not defined",f)}},writable:!1,configurable:!1,enumerable:!1}),$(i,"getBlocks",{value:function(){return this[u]},writable:!1,configurable:!1,enumerable:!1}),$(i,"setExtend",{value:function(e){this[a]=e},writable:!1,configurable:!1,enumerable:!1}),$(i,"getExtend",{value:function(){return this[a]},writable:!1,configurable:!1,enumerable:!1}),$(i,"setLayout",{value:function(e){this[l]=e},writable:!1,configurable:!1,enumerable:!1}),$(i,"getLayout",{value:function(){return this[l]},writable:!1,configurable:!1,enumerable:!1}),$(i,"clone",{value:function(e){var n=[l,a,s];return!0===e&&n.push(u),E(this,n)},writable:!1,configurable:!1,enumerable:!1}),$(i,"extend",{value:function(e){this.setExtend(!0),this.setLayout(e)},writable:!1,configurable:!1,enumerable:!1}),$(i,"echo",{value:function(e){var n=this.getBuffer();[].slice.call(arguments).forEach(n)},writable:!1,configurable:!1,enumerable:!1}),$(i,"fn",{value:function(e){var n=this.getBuffer(),r=this;return function(){return n.backup(),t(e)&&e.apply(r,arguments),n.restore()}},writable:!1,configurable:!1,enumerable:!1}),$(i,"get",{value:function(e,n){var t=m(this,e,!0),r=t.shift(),i=t.pop();return O(r,i)?r[i]:n},writable:!1,configurable:!1,enumerable:!1}),$(i,"set",{value:function(e,n){var t=m(this,e,!1),r=t.shift(),i=t.pop();return this.getExtend()&&O(r,i)?r[i]:r[i]=n},writable:!1,configurable:!1,enumerable:!1}),$(i,"macro",{value:function(e,n){var t=this.getMacro(),r=this.fn(n),i=this;t[e]=function(){return i.echo(r.apply(void 0,arguments))}},writable:!1,configurable:!1,enumerable:!1}),$(i,"call",{value:function(e){var n=this.getMacro()[e],r=[].slice.call(arguments,1);if(t(n))return n.apply(n,r)},writable:!1,configurable:!1,enumerable:!1}),$(i,"block",{value:function(e,n){var t=this,r=this.getBlocks();if(r[e]=r[e]||[],r[e].push(this.fn(n)),!this.getExtend()){var i=Object.assign([],r[e]),o=function(){return i.shift()};this.echo(o()(function e(){var n=o();return n?function(){t.echo(n(e()))}:y}()))}},writable:!1,configurable:!1,enumerable:!1}),$(i,"include",{value:function(e,n,t){var r=!1===t?{}:this.clone(!0),i=d(r,n||{}),o=this.render(e,i);this.echo(o)},writable:!1,configurable:!1,enumerable:!1}),$(i,"use",{value:function(e,n){var t=this.require(e);this.echo(j(t,(function(e){var t=this.getMacro();x(e,(function(e,r){t[[n,r].join(".")]=e}))}),this))},writable:!1,configurable:!1,enumerable:!1}),$(i,"async",{value:function(e,n){this.echo(j(e,(function(e){return this.fn(n)(e)}),this))},writable:!1,configurable:!1,enumerable:!1}),$(i,"each",{value:function(e,n){r(e)&&(e=this.get(e,[])),x(e,n)},writable:!1,configurable:!1,enumerable:!1}),$(i,"element",{value:function(e,n,t){return W(e,n,t)},writable:!1,configurable:!1,enumerable:!1}),$(i,"el",{value:function(e,n,r){t(r)&&(r=this.fn(r)()),this.echo(j(r,(function(t){return this.element(e,n,t)}),this))},writable:!1,configurable:!1,enumerable:!1}),i))},this.configure(e)}var K=new function e(n){if(!1===g(this,e))return new e(n);var t={},r={};F(r,n||{});var i=new D(r),o=new R(r),u=new B,c=new T(r,u,o),a=function(e,n){return c.get(e).then((function(e){return e.call(n,n,n.getComponent(),n.getBuffer(),v)}))},l=function e(n,t){var o=w(n,r.extension),u=i.create(t);return a(o,u).then((function(n){if(u.getExtend()){u.setExtend(!1);var t=u.getLayout(),r=u.clone();return e(t,r)}return n}))};return this.configure=function(e){return F(r,e=e||{}),i.configure(r,t),o.configure(r),u.configure(r),c.configure(r),r},this.render=function(e,n){return l(e,n)},this.helpers=function(e){i.helpers(d(t,e))},this.preload=function(e){return u.load(e||{})},this.create=function(n){return new e(n)},this.compile=function(e,n){return o.compile(e,n)},this.context=function(e){return i.create(e)},this.helpers({require:function(e){var n=w(e,r.extension),t=i.create({});return a(n,t).then((function(){return t.getMacro()}))},render:l}),this}({resolver:function(e,n){return fetch(function(e,n){return(n=[e,n].join("/")).replace(/\/\//g,"/")}(e,n)).then((function(e){return e.text()}),(function(e){return String(e)}))}}),X=K.render,Y=K.context,_=K.compile,z=K.helpers,G=K.preload,H=K.configure,I=K.create;e.compile=_,e.configure=H,e.context=Y,e.create=I,e.helpers=z,e.preload=G,e.render=X}));
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).ejs={})}(this,(function(e){"use strict";var n=function(){var e=[].slice.call(arguments),n=e.shift();return e.filter(n).pop()},t=function(e){return Array.isArray(e)},r=function(e){return"function"==typeof e},i=function(e){return"string"==typeof e},o=function(e){return"boolean"==typeof e},u=function(e){return void 0===e},c="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),a=function(){return c},l={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},s={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},f=function(e){return new RegExp(["[",Object.keys(e).join(""),"]"].join(""),"g")},h=f(s),p=f(l),b=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(h,(function(e){return s[e]}))},v=function(e){return(""+e).replace(p,(function(e){return"\\"+l[e]}))},g=function(e,n){var t=e;return null==t?"":!0===n?b(t):t},m=function(e,n){return Boolean(e instanceof n)},d=function(e,n,t){for(var i=e,o=String(n).split("."),u=o.pop(),c=0;c<o.length;c++){var a=o[c];if(r(i.toJSON)&&(i=i.toJSON()),t&&!1===i.hasOwnProperty(a)){i={};break}i=i[a]=i[a]||{}}return r(i.toJSON)&&(i=i.toJSON()),[i,u]},w=function(e,n){var t=e.split(".").pop();return t!==n&&(e=[e,n].join(".")),e},y=function(e){for(var n=arguments.length,t=new Array(n>1?n-1:0),r=1;r<n;r++)t[r-1]=arguments[r];return t.filter((function(e){return e})).reduce((function(e,n){return Object.assign(e,n)}),e)},j=function(){},E=function(e,n){var t;for(t in e)k(e,t)&&n(e[t],t,e)},x=function(e,n){return function(e,n,t){var r=e instanceof Array,i=r?[]:{};return E(e,(function(e,t,o){var c=n(e,t,o);!1===u(c)&&(r?i.push(c):i[t]=c)})),i}(e,(function(e,t){if(-1===n.indexOf(t))return e}))},O=function(e,n,t){return Promise.resolve(e).then(n.bind(t))},k=function(e,n){return e&&e.hasOwnProperty(n)},F={export:"ejsPrecompiled",cache:!0,chokidar:null,path:"views",resolver:function(e,n){return Promise.resolve(["resolver is not defined",e,n].join(" "))},extension:"ejs",rmWhitespace:!0,withObject:!0,globalHelpers:[],vars:{SCOPE:"ejs",COMPONENT:"ui",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},S=function(e,u){y(e,{path:n(i,F.path,e.path,u.path),export:n(i,F.export,e.export,u.export),resolver:n(r,F.resolver,e.resolver,u.resolver),extension:n(i,F.extension,e.extension,u.extension),withObject:n(o,F.withObject,e.withObject,u.withObject),rmWhitespace:n(o,F.rmWhitespace,e.rmWhitespace,u.rmWhitespace),cache:n(o,F.cache,e.cache,u.cache),token:y({},F.token,e.token,u.token),vars:y({},F.vars,e.vars,u.vars),globalHelpers:n(t,F.globalHelpers,e.globalHelpers,u.globalHelpers)})},B="undefined"!=typeof globalThis?globalThis:window||self;function P(e){if(!1===m(this,P))return new P;var n={enabled:!0,list:{}};this.configure=function(e){n.enabled=e.cache,!1===a()&&this.load(B[e.export])},this.clear=function(){n.list={}},this.load=function(e){return n.enabled&&y(n.list,e||{}),this},this.get=function(e){if(n.enabled)return n.list[e]},this.set=function(e,t){return n.enabled&&(n.list[e]=t),this},this.resolve=function(e){return Promise.resolve(this.get(e))},this.remove=function(e){delete n.list[e]},this.exist=function(e){return k(n.list,e)}}var R=[{symbol:"-",format:function(e){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(e,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(e){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(e,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(e){return"')\n/**".concat(e,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(e){return"')\n".concat(e.trim(),"\n").concat(this.BUFFER,"('")}}];function T(e){if(!1===m(this,T))return new T(e);var n={};this.configure=function(e){n.withObject=e.withObject,n.rmWhitespace=e.rmWhitespace,n.token=e.token,n.vars=e.vars,n.globalHelpers=e.globalHelpers,n.matches=[],n.formats=[],n.slurp={match:"[ \\t]*",start:[n.token.start,"_"],end:["_",n.token.end]},R.forEach((function(e){n.matches.push(n.token.start.concat(e.symbol).concat(n.token.regex).concat(n.token.end)),n.formats.push(e.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(e,t){var r=n.vars,i=r.SCOPE,o=r.SAFE,u=r.BUFFER,c=r.COMPONENT,a=n.globalHelpers;n.rmWhitespace&&(e=e.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),e=e.replace(n.slurpStart,n.token.start).replace(n.slurpEnd,n.token.end);var l,s,f,h="".concat(u,"('");l=n.regex,s=function(t,r,i){h+=v(e.slice(r,i)),t.forEach((function(e,t){e&&(h+=n.formats[t](e))}))},f=0,e.replace(l,(function(){var e=[].slice.call(arguments,0,-1),n=e.pop(),t=e.shift();return s(e,f,n),f=n+t.length,t})),h="try{".concat(h+="');","}catch(e){console.info(e)}"),n.withObject&&(h="with(".concat(i,"){").concat(h,"}")),h="".concat(u,".start();").concat(h,"return ").concat(u,".end();"),h+="\n//# sourceURL=".concat(t);var p=null,b=[i,c,u,o].concat(a);try{(p=Function.apply(null,b.concat(h))).source="(function(".concat(b.join(","),"){\n").concat(h,"\n})")}catch(e){throw e.filename=t,e.source=h,e}return p},this.configure(e)}function $(e,n,t){if(!1===m(this,$))return new $(e,n,t);if(!1===m(n,P))throw new TypeError("cache is not instance of Cache");if(!1===m(t,T))throw new TypeError("compiler is not instance of Compiler");var i={},o=function(e){return i.resolver(i.path,e)};this.configure=function(e){i.path=e.path,i.cache=e.cache,r(e.resolver)&&(i.resolver=e.resolver)},this.get=function(e){return n.exist(e)?n.resolve(e):o(e).then((function(i){return function(e,t){return n.set(e,t),t}(e,function(e,n){return r(e)?e:t.compile(e,n)}(i,e))}))},this.configure(e)}function A(e,n,t){return(n=function(e){var n=function(e,n){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,n||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(e,"string");return"symbol"==typeof n?n:String(n)}(n))in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var C=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],N=" ",U='"',M="/",H="<",L=">",W=function(e,n,t){var r=[],i=-1===C.indexOf(e),o=function(e,n,t){var r=[];return E(e,(function(e,t,i){var o=n(e,t,i);!1===u(o)&&r.push(o)})),r}(n,(function(e,n){if(null!=e)return[b(n),[U,b(e),U].join("")].join("=")})).join(N);return r.push([H,e,N,o,L].join("")),t&&r.push(t instanceof Array?t.join(""):t),i&&r.push([H,M,e,L].join("")),r.join("")};function J(e){return Promise.all(e||[]).then((function(e){return e.join("")}))}function q(){var e=[],n=[];function t(e){n.push(e)}return t.start=function(){n=[]},t.backup=function(){e.push(n.concat()),n=[]},t.restore=function(){var t=n.concat();return n=e.pop(),J(t)},t.error=function(e){throw e},t.end=function(){return J(n)},t}function D(e){if(!1===m(this,D))return new D(e);this.configure=function(e,n){var t,o=e.vars,u=o.BLOCKS,c=o.MACRO,a=o.EXTEND,l=o.LAYOUT,s=o.BUFFER,f=o.COMPONENT;function h(e){this[u]={},this[c]={},y(this,e||{})}this.create=function(e){return new h(e)},this.helpers=function(e){y(h.prototype,e||{})},h.prototype=y({},n||{}),Object.defineProperties(h.prototype,(A(t={},s,{value:q(),writable:!0,configurable:!1,enumerable:!1}),A(t,u,{value:{},writable:!0,configurable:!1,enumerable:!1}),A(t,c,{value:{},writable:!0,configurable:!1,enumerable:!1}),A(t,l,{value:!1,writable:!0,configurable:!1,enumerable:!1}),A(t,a,{value:!1,writable:!0,configurable:!1,enumerable:!1}),A(t,"getMacro",{value:function(){return this[c]},writable:!1,configurable:!1,enumerable:!1}),A(t,"getBuffer",{value:function(){return this[s]},writable:!1,configurable:!1,enumerable:!1}),A(t,"getComponent",{value:function(){var e=this;return f in e?function(){return e[f].apply(e,arguments)}:function(){console.log("%s function not defined",f)}},writable:!1,configurable:!1,enumerable:!1}),A(t,"getBlocks",{value:function(){return this[u]},writable:!1,configurable:!1,enumerable:!1}),A(t,"setExtend",{value:function(e){this[a]=e},writable:!1,configurable:!1,enumerable:!1}),A(t,"getExtend",{value:function(){return this[a]},writable:!1,configurable:!1,enumerable:!1}),A(t,"setLayout",{value:function(e){this[l]=e},writable:!1,configurable:!1,enumerable:!1}),A(t,"getLayout",{value:function(){return this[l]},writable:!1,configurable:!1,enumerable:!1}),A(t,"clone",{value:function(e){var n=[l,a,s];return!0===e&&n.push(u),x(this,n)},writable:!1,configurable:!1,enumerable:!1}),A(t,"extend",{value:function(e){this.setExtend(!0),this.setLayout(e)},writable:!1,configurable:!1,enumerable:!1}),A(t,"echo",{value:function(e){var n=this.getBuffer();[].slice.call(arguments).forEach(n)},writable:!1,configurable:!1,enumerable:!1}),A(t,"fn",{value:function(e){var n=this.getBuffer(),t=this;return function(){return n.backup(),r(e)&&e.apply(t,arguments),n.restore()}},writable:!1,configurable:!1,enumerable:!1}),A(t,"get",{value:function(e,n){var t=d(this,e,!0),r=t.shift(),i=t.pop();return k(r,i)?r[i]:n},writable:!1,configurable:!1,enumerable:!1}),A(t,"set",{value:function(e,n){var t=d(this,e,!1),r=t.shift(),i=t.pop();return this.getExtend()&&k(r,i)?r[i]:r[i]=n},writable:!1,configurable:!1,enumerable:!1}),A(t,"macro",{value:function(e,n){var t=this.getMacro(),r=this.fn(n),i=this;t[e]=function(){return i.echo(r.apply(void 0,arguments))}},writable:!1,configurable:!1,enumerable:!1}),A(t,"call",{value:function(e){var n=this.getMacro()[e],t=[].slice.call(arguments,1);if(r(n))return n.apply(n,t)},writable:!1,configurable:!1,enumerable:!1}),A(t,"block",{value:function(e,n){var t=this,r=this.getBlocks();if(r[e]=r[e]||[],r[e].push(this.fn(n)),!this.getExtend()){var i=Object.assign([],r[e]),o=function(){return i.shift()};this.echo(o()(function e(){var n=o();return n?function(){t.echo(n(e()))}:j}()))}},writable:!1,configurable:!1,enumerable:!1}),A(t,"include",{value:function(e,n,t){var r=!1===t?{}:this.clone(!0),i=y(r,n||{}),o=this.render(e,i);this.echo(o)},writable:!1,configurable:!1,enumerable:!1}),A(t,"use",{value:function(e,n){var t=this.require(e);this.echo(O(t,(function(e){var t=this.getMacro();E(e,(function(e,r){t[[n,r].join(".")]=e}))}),this))},writable:!1,configurable:!1,enumerable:!1}),A(t,"async",{value:function(e,n){this.echo(O(e,(function(e){return this.fn(n)(e)}),this))},writable:!1,configurable:!1,enumerable:!1}),A(t,"each",{value:function(e,n){i(e)&&(e=this.get(e,[])),E(e,n)},writable:!1,configurable:!1,enumerable:!1}),A(t,"element",{value:function(e,n,t){return W(e,n,t)},writable:!1,configurable:!1,enumerable:!1}),A(t,"el",{value:function(e,n,t){r(t)&&(t=this.fn(t)()),this.echo(O(t,(function(t){return this.element(e,n,t)}),this))},writable:!1,configurable:!1,enumerable:!1}),t))},this.configure(e)}var K=new function e(n){if(!1===m(this,e))return new e(n);var t={},i={};S(i,n||{});var o=new D(i),u=new T(i),c=new P,a=new $(i,c,u),l=function(e,n){var t=[n,n.getComponent(),n.getBuffer(),g];return i.globalHelpers.forEach((function(e){r(n[e])&&t.push(n[e].bind(n))})),a.get(e).then((function(e){return e.apply(n,t)}))},s=function e(n,t){var r=w(n,i.extension),u=o.create(t);return l(r,u).then((function(n){if(u.getExtend()){u.setExtend(!1);var t=u.getLayout(),r=u.clone();return e(t,r)}return n}))};return this.configure=function(e){return S(i,e=e||{}),o.configure(i,t),u.configure(i),c.configure(i),a.configure(i),i},this.render=function(e,n){return s(e,n)},this.helpers=function(e){o.helpers(y(t,e))},this.preload=function(e){return c.load(e||{})},this.create=function(n){return new e(n)},this.compile=function(e,n){return u.compile(e,n)},this.context=function(e){return o.create(e)},this.helpers({require:function(e){var n=w(e,i.extension),t=o.create({});return l(n,t).then((function(){return t.getMacro()}))},render:s}),this}({resolver:function(e,n){return fetch(function(e,n){return(n=[e,n].join("/")).replace(/\/\//g,"/")}(e,n)).then((function(e){return e.text()}),(function(e){return String(e)}))}}),X=K.render,Y=K.context,_=K.compile,z=K.helpers,G=K.preload,I=K.configure,Q=K.create;e.compile=_,e.configure=I,e.context=Y,e.create=Q,e.helpers=z,e.preload=G,e.render=X}));
package/dist/umd/index.js CHANGED
@@ -9,6 +9,9 @@
9
9
  var callback = args.shift();
10
10
  return args.filter(callback).pop();
11
11
  };
12
+ var isArray = function isArray(v) {
13
+ return Array.isArray(v);
14
+ };
12
15
  var isFunction = function isFunction(v) {
13
16
  return typeof v === 'function';
14
17
  };
@@ -170,6 +173,7 @@
170
173
  defaults.extension = 'ejs';
171
174
  defaults.rmWhitespace = true;
172
175
  defaults.withObject = true;
176
+ defaults.globalHelpers = [];
173
177
  defaults.vars = {
174
178
  SCOPE: 'ejs',
175
179
  COMPONENT: 'ui',
@@ -196,7 +200,8 @@
196
200
  rmWhitespace: typeProp(isBoolean, defaults.rmWhitespace, config.rmWhitespace, options.rmWhitespace),
197
201
  cache: typeProp(isBoolean, defaults.cache, config.cache, options.cache),
198
202
  token: extend({}, defaults.token, config.token, options.token),
199
- vars: extend({}, defaults.vars, config.vars, options.vars)
203
+ vars: extend({}, defaults.vars, config.vars, options.vars),
204
+ globalHelpers: typeProp(isArray, defaults.globalHelpers, config.globalHelpers, options.globalHelpers)
200
205
  });
201
206
  };
202
207
 
@@ -284,6 +289,7 @@
284
289
  compiler.rmWhitespace = config.rmWhitespace;
285
290
  compiler.token = config.token;
286
291
  compiler.vars = config.vars;
292
+ compiler.globalHelpers = config.globalHelpers;
287
293
  compiler.matches = [];
288
294
  compiler.formats = [];
289
295
  compiler.slurp = {
@@ -305,6 +311,7 @@
305
311
  SAFE = _compiler$vars.SAFE,
306
312
  BUFFER = _compiler$vars.BUFFER,
307
313
  COMPONENT = _compiler$vars.COMPONENT;
314
+ var GLOBALS = compiler.globalHelpers;
308
315
  if (compiler.rmWhitespace) {
309
316
  content = content.replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
310
317
  }
@@ -326,9 +333,10 @@
326
333
  source = "".concat(BUFFER, ".start();").concat(source, "return ").concat(BUFFER, ".end();");
327
334
  source += "\n//# sourceURL=".concat(path);
328
335
  var result = null;
336
+ var params = [SCOPE, COMPONENT, BUFFER, SAFE].concat(GLOBALS);
329
337
  try {
330
- result = new Function(SCOPE, COMPONENT, BUFFER, SAFE, source);
331
- result.source = "(function(".concat(SCOPE, ",").concat(COMPONENT, ",").concat(BUFFER, ",").concat(SAFE, "){\n").concat(source, "\n})");
338
+ result = Function.apply(null, params.concat(source));
339
+ result.source = "(function(".concat(params.join(','), "){\n").concat(source, "\n})");
332
340
  } catch (e) {
333
341
  e.filename = path;
334
342
  e.source = source;
@@ -765,9 +773,13 @@
765
773
  var compiler = new Compiler(config);
766
774
  var cache = new Cache();
767
775
  var template = new Template(config, cache, compiler);
768
- var output = function output(path, scope) {
776
+ var output = function output(path, context) {
777
+ var params = [context, context.getComponent(), context.getBuffer(), safeValue];
778
+ config.globalHelpers.forEach(function (name) {
779
+ if (isFunction(context[name])) params.push(context[name].bind(context));
780
+ });
769
781
  return template.get(path).then(function (callback) {
770
- return callback.call(scope, scope, scope.getComponent(), scope.getBuffer(), safeValue);
782
+ return callback.apply(context, params);
771
783
  });
772
784
  };
773
785
  var require = function require(name) {
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).ejs={})}(this,(function(e){"use strict";var n=function(){var e=[].slice.call(arguments),n=e.shift();return e.filter(n).pop()},t=function(e){return"function"==typeof e},r=function(e){return"string"==typeof e},i=function(e){return"boolean"==typeof e},o=function(e){return void 0===e},u="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),c=function(){return u},a={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},s={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},l=function(e){return new RegExp(["[",Object.keys(e).join(""),"]"].join(""),"g")},f=l(s),h=l(a),p=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(f,(function(e){return s[e]}))},b=function(e){return(""+e).replace(h,(function(e){return"\\"+a[e]}))},v=function(e,n){var t=e;return null==t?"":!0===n?p(t):t},g=function(e,n){return Boolean(e instanceof n)},m=function(e,n,r){for(var i=e,o=String(n).split("."),u=o.pop(),c=0;c<o.length;c++){var a=o[c];if(t(i.toJSON)&&(i=i.toJSON()),r&&!1===i.hasOwnProperty(a)){i={};break}i=i[a]=i[a]||{}}return t(i.toJSON)&&(i=i.toJSON()),[i,u]},w=function(e,n){var t=e.split(".").pop();return t!==n&&(e=[e,n].join(".")),e},d=function(e){for(var n=arguments.length,t=new Array(n>1?n-1:0),r=1;r<n;r++)t[r-1]=arguments[r];return t.filter((function(e){return e})).reduce((function(e,n){return Object.assign(e,n)}),e)},y=function(){},j=function(e,n){var t;for(t in e)O(e,t)&&n(e[t],t,e)},x=function(e,n){return function(e,n,t){var r=e instanceof Array,i=r?[]:{};return j(e,(function(e,t,u){var c=n(e,t,u);!1===o(c)&&(r?i.push(c):i[t]=c)})),i}(e,(function(e,t){if(-1===n.indexOf(t))return e}))},E=function(e,n,t){return Promise.resolve(e).then(n.bind(t))},O=function(e,n){return e&&e.hasOwnProperty(n)},k={export:"ejsPrecompiled",cache:!0,chokidar:null,path:"views",resolver:function(e,n){return Promise.resolve(["resolver is not defined",e,n].join(" "))},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]+?)"}},F=function(e,o){d(e,{path:n(r,k.path,e.path,o.path),export:n(r,k.export,e.export,o.export),resolver:n(t,k.resolver,e.resolver,o.resolver),extension:n(r,k.extension,e.extension,o.extension),withObject:n(i,k.withObject,e.withObject,o.withObject),rmWhitespace:n(i,k.rmWhitespace,e.rmWhitespace,o.rmWhitespace),cache:n(i,k.cache,e.cache,o.cache),token:d({},k.token,e.token,o.token),vars:d({},k.vars,e.vars,o.vars)})},S="undefined"!=typeof globalThis?globalThis:window||self;function B(e){if(!1===g(this,B))return new B;var n={enabled:!0,list:{}};this.configure=function(e){n.enabled=e.cache,!1===c()&&this.load(S[e.export])},this.clear=function(){n.list={}},this.load=function(e){return n.enabled&&d(n.list,e||{}),this},this.get=function(e){if(n.enabled)return n.list[e]},this.set=function(e,t){return n.enabled&&(n.list[e]=t),this},this.resolve=function(e){return Promise.resolve(this.get(e))},this.remove=function(e){delete n.list[e]},this.exist=function(e){return O(n.list,e)}}var P=[{symbol:"-",format:function(e){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(e,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(e){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(e,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(e){return"')\n/**".concat(e,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(e){return"')\n".concat(e.trim(),"\n").concat(this.BUFFER,"('")}}];function R(e){if(!1===g(this,R))return new R(e);var n={};this.configure=function(e){n.withObject=e.withObject,n.rmWhitespace=e.rmWhitespace,n.token=e.token,n.vars=e.vars,n.matches=[],n.formats=[],n.slurp={match:"[ \\t]*",start:[n.token.start,"_"],end:["_",n.token.end]},P.forEach((function(e){n.matches.push(n.token.start.concat(e.symbol).concat(n.token.regex).concat(n.token.end)),n.formats.push(e.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(e,t){var r=n.vars,i=r.SCOPE,o=r.SAFE,u=r.BUFFER,c=r.COMPONENT;n.rmWhitespace&&(e=e.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),e=e.replace(n.slurpStart,n.token.start).replace(n.slurpEnd,n.token.end);var a,s,l,f="".concat(u,"('");a=n.regex,s=function(t,r,i){f+=b(e.slice(r,i)),t.forEach((function(e,t){e&&(f+=n.formats[t](e))}))},l=0,e.replace(a,(function(){var e=[].slice.call(arguments,0,-1),n=e.pop(),t=e.shift();return s(e,l,n),l=n+t.length,t})),f="try{".concat(f+="');","}catch(e){console.info(e)}"),n.withObject&&(f="with(".concat(i,"){").concat(f,"}")),f="".concat(u,".start();").concat(f,"return ").concat(u,".end();"),f+="\n//# sourceURL=".concat(t);var h=null;try{(h=new Function(i,c,u,o,f)).source="(function(".concat(i,",").concat(c,",").concat(u,",").concat(o,"){\n").concat(f,"\n})")}catch(e){throw e.filename=t,e.source=f,e}return h},this.configure(e)}function T(e,n,r){if(!1===g(this,T))return new T(e,n,r);if(!1===g(n,B))throw new TypeError("cache is not instance of Cache");if(!1===g(r,R))throw new TypeError("compiler is not instance of Compiler");var i={},o=function(e){return i.resolver(i.path,e)};this.configure=function(e){i.path=e.path,i.cache=e.cache,t(e.resolver)&&(i.resolver=e.resolver)},this.get=function(e){return n.exist(e)?n.resolve(e):o(e).then((function(i){return function(e,t){return n.set(e,t),t}(e,function(e,n){return t(e)?e:r.compile(e,n)}(i,e))}))},this.configure(e)}function $(e,n,t){return(n=function(e){var n=function(e,n){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,n||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(e,"string");return"symbol"==typeof n?n:String(n)}(n))in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var C=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],N=" ",U='"',A="/",M="<",L=">",W=function(e,n,t){var r=[],i=-1===C.indexOf(e),u=function(e,n,t){var r=[];return j(e,(function(e,t,i){var u=n(e,t,i);!1===o(u)&&r.push(u)})),r}(n,(function(e,n){if(null!=e)return[p(n),[U,p(e),U].join("")].join("=")})).join(N);return r.push([M,e,N,u,L].join("")),t&&r.push(t instanceof Array?t.join(""):t),i&&r.push([M,A,e,L].join("")),r.join("")};function J(e){return Promise.all(e||[]).then((function(e){return e.join("")}))}function _(){var e=[],n=[];function t(e){n.push(e)}return t.start=function(){n=[]},t.backup=function(){e.push(n.concat()),n=[]},t.restore=function(){var t=n.concat();return n=e.pop(),J(t)},t.error=function(e){throw e},t.end=function(){return J(n)},t}function q(e){if(!1===g(this,q))return new q(e);this.configure=function(e,n){var i,o=e.vars,u=o.BLOCKS,c=o.MACRO,a=o.EXTEND,s=o.LAYOUT,l=o.BUFFER,f=o.COMPONENT;function h(e){this[u]={},this[c]={},d(this,e||{})}this.create=function(e){return new h(e)},this.helpers=function(e){d(h.prototype,e||{})},h.prototype=d({},n||{}),Object.defineProperties(h.prototype,($(i={},l,{value:_(),writable:!0,configurable:!1,enumerable:!1}),$(i,u,{value:{},writable:!0,configurable:!1,enumerable:!1}),$(i,c,{value:{},writable:!0,configurable:!1,enumerable:!1}),$(i,s,{value:!1,writable:!0,configurable:!1,enumerable:!1}),$(i,a,{value:!1,writable:!0,configurable:!1,enumerable:!1}),$(i,"getMacro",{value:function(){return this[c]},writable:!1,configurable:!1,enumerable:!1}),$(i,"getBuffer",{value:function(){return this[l]},writable:!1,configurable:!1,enumerable:!1}),$(i,"getComponent",{value:function(){var e=this;return f in e?function(){return e[f].apply(e,arguments)}:function(){console.log("%s function not defined",f)}},writable:!1,configurable:!1,enumerable:!1}),$(i,"getBlocks",{value:function(){return this[u]},writable:!1,configurable:!1,enumerable:!1}),$(i,"setExtend",{value:function(e){this[a]=e},writable:!1,configurable:!1,enumerable:!1}),$(i,"getExtend",{value:function(){return this[a]},writable:!1,configurable:!1,enumerable:!1}),$(i,"setLayout",{value:function(e){this[s]=e},writable:!1,configurable:!1,enumerable:!1}),$(i,"getLayout",{value:function(){return this[s]},writable:!1,configurable:!1,enumerable:!1}),$(i,"clone",{value:function(e){var n=[s,a,l];return!0===e&&n.push(u),x(this,n)},writable:!1,configurable:!1,enumerable:!1}),$(i,"extend",{value:function(e){this.setExtend(!0),this.setLayout(e)},writable:!1,configurable:!1,enumerable:!1}),$(i,"echo",{value:function(e){var n=this.getBuffer();[].slice.call(arguments).forEach(n)},writable:!1,configurable:!1,enumerable:!1}),$(i,"fn",{value:function(e){var n=this.getBuffer(),r=this;return function(){return n.backup(),t(e)&&e.apply(r,arguments),n.restore()}},writable:!1,configurable:!1,enumerable:!1}),$(i,"get",{value:function(e,n){var t=m(this,e,!0),r=t.shift(),i=t.pop();return O(r,i)?r[i]:n},writable:!1,configurable:!1,enumerable:!1}),$(i,"set",{value:function(e,n){var t=m(this,e,!1),r=t.shift(),i=t.pop();return this.getExtend()&&O(r,i)?r[i]:r[i]=n},writable:!1,configurable:!1,enumerable:!1}),$(i,"macro",{value:function(e,n){var t=this.getMacro(),r=this.fn(n),i=this;t[e]=function(){return i.echo(r.apply(void 0,arguments))}},writable:!1,configurable:!1,enumerable:!1}),$(i,"call",{value:function(e){var n=this.getMacro()[e],r=[].slice.call(arguments,1);if(t(n))return n.apply(n,r)},writable:!1,configurable:!1,enumerable:!1}),$(i,"block",{value:function(e,n){var t=this,r=this.getBlocks();if(r[e]=r[e]||[],r[e].push(this.fn(n)),!this.getExtend()){var i=Object.assign([],r[e]),o=function(){return i.shift()};this.echo(o()(function e(){var n=o();return n?function(){t.echo(n(e()))}:y}()))}},writable:!1,configurable:!1,enumerable:!1}),$(i,"include",{value:function(e,n,t){var r=!1===t?{}:this.clone(!0),i=d(r,n||{}),o=this.render(e,i);this.echo(o)},writable:!1,configurable:!1,enumerable:!1}),$(i,"use",{value:function(e,n){var t=this.require(e);this.echo(E(t,(function(e){var t=this.getMacro();j(e,(function(e,r){t[[n,r].join(".")]=e}))}),this))},writable:!1,configurable:!1,enumerable:!1}),$(i,"async",{value:function(e,n){this.echo(E(e,(function(e){return this.fn(n)(e)}),this))},writable:!1,configurable:!1,enumerable:!1}),$(i,"each",{value:function(e,n){r(e)&&(e=this.get(e,[])),j(e,n)},writable:!1,configurable:!1,enumerable:!1}),$(i,"element",{value:function(e,n,t){return W(e,n,t)},writable:!1,configurable:!1,enumerable:!1}),$(i,"el",{value:function(e,n,r){t(r)&&(r=this.fn(r)()),this.echo(E(r,(function(t){return this.element(e,n,t)}),this))},writable:!1,configurable:!1,enumerable:!1}),i))},this.configure(e)}var D={};var K=new function e(n){if(!1===g(this,e))return new e(n);var t={},r={};F(r,n||{});var i=new q(r),o=new R(r),u=new B,c=new T(r,u,o),a=function(e,n){return c.get(e).then((function(e){return e.call(n,n,n.getComponent(),n.getBuffer(),v)}))},s=function e(n,t){var o=w(n,r.extension),u=i.create(t);return a(o,u).then((function(n){if(u.getExtend()){u.setExtend(!1);var t=u.getLayout(),r=u.clone();return e(t,r)}return n}))};return this.configure=function(e){return F(r,e=e||{}),i.configure(r,t),o.configure(r),u.configure(r),c.configure(r),r},this.render=function(e,n){return s(e,n)},this.helpers=function(e){i.helpers(d(t,e))},this.preload=function(e){return u.load(e||{})},this.create=function(n){return new e(n)},this.compile=function(e,n){return o.compile(e,n)},this.context=function(e){return i.create(e)},this.helpers({require:function(e){var n=w(e,r.extension),t=i.create({});return a(n,t).then((function(){return t.getMacro()}))},render:s}),this}({resolver:function(e,n){return new Promise((function(t,r){D.readFile(function(e,n){return(n=[e,n].join("/")).replace(/\/\//g,"/")}(e,n),(function(e,n){e?r(e):t(n.toString())}))}))}}),X=K.render,Y=K.context,z=K.compile,G=K.helpers,H=K.preload,I=K.configure,Q=K.create,V=function(e){return function(o,u,c){t(u)&&(c=u,u={});var a=d({},(u=u||{}).settings),s=n(r,k.path,a.views),l=n(i,k.cache,a["view cache"]),f=d({},a["view options"]),h=D.relative(s,o);return f.path=s,f.cache=l,e.configure(f),e.render(h,u).then((function(e){c(null,e)})).catch((function(e){c(e)}))}}(K);e.__express=V,e.compile=z,e.configure=I,e.context=Y,e.create=Q,e.helpers=G,e.preload=H,e.render=X}));
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).ejs={})}(this,(function(e){"use strict";var n=function(){var e=[].slice.call(arguments),n=e.shift();return e.filter(n).pop()},t=function(e){return Array.isArray(e)},r=function(e){return"function"==typeof e},i=function(e){return"string"==typeof e},o=function(e){return"boolean"==typeof e},u=function(e){return void 0===e},c="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),a=function(){return c},l={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},s={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"},f=function(e){return new RegExp(["[",Object.keys(e).join(""),"]"].join(""),"g")},h=f(s),p=f(l),b=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(h,(function(e){return s[e]}))},v=function(e){return(""+e).replace(p,(function(e){return"\\"+l[e]}))},g=function(e,n){var t=e;return null==t?"":!0===n?b(t):t},m=function(e,n){return Boolean(e instanceof n)},w=function(e,n,t){for(var i=e,o=String(n).split("."),u=o.pop(),c=0;c<o.length;c++){var a=o[c];if(r(i.toJSON)&&(i=i.toJSON()),t&&!1===i.hasOwnProperty(a)){i={};break}i=i[a]=i[a]||{}}return r(i.toJSON)&&(i=i.toJSON()),[i,u]},d=function(e,n){var t=e.split(".").pop();return t!==n&&(e=[e,n].join(".")),e},y=function(e){for(var n=arguments.length,t=new Array(n>1?n-1:0),r=1;r<n;r++)t[r-1]=arguments[r];return t.filter((function(e){return e})).reduce((function(e,n){return Object.assign(e,n)}),e)},j=function(){},E=function(e,n){var t;for(t in e)k(e,t)&&n(e[t],t,e)},x=function(e,n){return function(e,n,t){var r=e instanceof Array,i=r?[]:{};return E(e,(function(e,t,o){var c=n(e,t,o);!1===u(c)&&(r?i.push(c):i[t]=c)})),i}(e,(function(e,t){if(-1===n.indexOf(t))return e}))},O=function(e,n,t){return Promise.resolve(e).then(n.bind(t))},k=function(e,n){return e&&e.hasOwnProperty(n)},F={export:"ejsPrecompiled",cache:!0,chokidar:null,path:"views",resolver:function(e,n){return Promise.resolve(["resolver is not defined",e,n].join(" "))},extension:"ejs",rmWhitespace:!0,withObject:!0,globalHelpers:[],vars:{SCOPE:"ejs",COMPONENT:"ui",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},S=function(e,u){y(e,{path:n(i,F.path,e.path,u.path),export:n(i,F.export,e.export,u.export),resolver:n(r,F.resolver,e.resolver,u.resolver),extension:n(i,F.extension,e.extension,u.extension),withObject:n(o,F.withObject,e.withObject,u.withObject),rmWhitespace:n(o,F.rmWhitespace,e.rmWhitespace,u.rmWhitespace),cache:n(o,F.cache,e.cache,u.cache),token:y({},F.token,e.token,u.token),vars:y({},F.vars,e.vars,u.vars),globalHelpers:n(t,F.globalHelpers,e.globalHelpers,u.globalHelpers)})},B="undefined"!=typeof globalThis?globalThis:window||self;function P(e){if(!1===m(this,P))return new P;var n={enabled:!0,list:{}};this.configure=function(e){n.enabled=e.cache,!1===a()&&this.load(B[e.export])},this.clear=function(){n.list={}},this.load=function(e){return n.enabled&&y(n.list,e||{}),this},this.get=function(e){if(n.enabled)return n.list[e]},this.set=function(e,t){return n.enabled&&(n.list[e]=t),this},this.resolve=function(e){return Promise.resolve(this.get(e))},this.remove=function(e){delete n.list[e]},this.exist=function(e){return k(n.list,e)}}var R=[{symbol:"-",format:function(e){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(e,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(e){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(e,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(e){return"')\n/**".concat(e,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(e){return"')\n".concat(e.trim(),"\n").concat(this.BUFFER,"('")}}];function T(e){if(!1===m(this,T))return new T(e);var n={};this.configure=function(e){n.withObject=e.withObject,n.rmWhitespace=e.rmWhitespace,n.token=e.token,n.vars=e.vars,n.globalHelpers=e.globalHelpers,n.matches=[],n.formats=[],n.slurp={match:"[ \\t]*",start:[n.token.start,"_"],end:["_",n.token.end]},R.forEach((function(e){n.matches.push(n.token.start.concat(e.symbol).concat(n.token.regex).concat(n.token.end)),n.formats.push(e.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(e,t){var r=n.vars,i=r.SCOPE,o=r.SAFE,u=r.BUFFER,c=r.COMPONENT,a=n.globalHelpers;n.rmWhitespace&&(e=e.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),e=e.replace(n.slurpStart,n.token.start).replace(n.slurpEnd,n.token.end);var l,s,f,h="".concat(u,"('");l=n.regex,s=function(t,r,i){h+=v(e.slice(r,i)),t.forEach((function(e,t){e&&(h+=n.formats[t](e))}))},f=0,e.replace(l,(function(){var e=[].slice.call(arguments,0,-1),n=e.pop(),t=e.shift();return s(e,f,n),f=n+t.length,t})),h="try{".concat(h+="');","}catch(e){console.info(e)}"),n.withObject&&(h="with(".concat(i,"){").concat(h,"}")),h="".concat(u,".start();").concat(h,"return ").concat(u,".end();"),h+="\n//# sourceURL=".concat(t);var p=null,b=[i,c,u,o].concat(a);try{(p=Function.apply(null,b.concat(h))).source="(function(".concat(b.join(","),"){\n").concat(h,"\n})")}catch(e){throw e.filename=t,e.source=h,e}return p},this.configure(e)}function $(e,n,t){if(!1===m(this,$))return new $(e,n,t);if(!1===m(n,P))throw new TypeError("cache is not instance of Cache");if(!1===m(t,T))throw new TypeError("compiler is not instance of Compiler");var i={},o=function(e){return i.resolver(i.path,e)};this.configure=function(e){i.path=e.path,i.cache=e.cache,r(e.resolver)&&(i.resolver=e.resolver)},this.get=function(e){return n.exist(e)?n.resolve(e):o(e).then((function(i){return function(e,t){return n.set(e,t),t}(e,function(e,n){return r(e)?e:t.compile(e,n)}(i,e))}))},this.configure(e)}function A(e,n,t){return(n=function(e){var n=function(e,n){if("object"!=typeof e||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,n||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(e,"string");return"symbol"==typeof n?n:String(n)}(n))in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var C=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],N=" ",U='"',M="/",H="<",L=">",W=function(e,n,t){var r=[],i=-1===C.indexOf(e),o=function(e,n,t){var r=[];return E(e,(function(e,t,i){var o=n(e,t,i);!1===u(o)&&r.push(o)})),r}(n,(function(e,n){if(null!=e)return[b(n),[U,b(e),U].join("")].join("=")})).join(N);return r.push([H,e,N,o,L].join("")),t&&r.push(t instanceof Array?t.join(""):t),i&&r.push([H,M,e,L].join("")),r.join("")};function J(e){return Promise.all(e||[]).then((function(e){return e.join("")}))}function _(){var e=[],n=[];function t(e){n.push(e)}return t.start=function(){n=[]},t.backup=function(){e.push(n.concat()),n=[]},t.restore=function(){var t=n.concat();return n=e.pop(),J(t)},t.error=function(e){throw e},t.end=function(){return J(n)},t}function q(e){if(!1===m(this,q))return new q(e);this.configure=function(e,n){var t,o=e.vars,u=o.BLOCKS,c=o.MACRO,a=o.EXTEND,l=o.LAYOUT,s=o.BUFFER,f=o.COMPONENT;function h(e){this[u]={},this[c]={},y(this,e||{})}this.create=function(e){return new h(e)},this.helpers=function(e){y(h.prototype,e||{})},h.prototype=y({},n||{}),Object.defineProperties(h.prototype,(A(t={},s,{value:_(),writable:!0,configurable:!1,enumerable:!1}),A(t,u,{value:{},writable:!0,configurable:!1,enumerable:!1}),A(t,c,{value:{},writable:!0,configurable:!1,enumerable:!1}),A(t,l,{value:!1,writable:!0,configurable:!1,enumerable:!1}),A(t,a,{value:!1,writable:!0,configurable:!1,enumerable:!1}),A(t,"getMacro",{value:function(){return this[c]},writable:!1,configurable:!1,enumerable:!1}),A(t,"getBuffer",{value:function(){return this[s]},writable:!1,configurable:!1,enumerable:!1}),A(t,"getComponent",{value:function(){var e=this;return f in e?function(){return e[f].apply(e,arguments)}:function(){console.log("%s function not defined",f)}},writable:!1,configurable:!1,enumerable:!1}),A(t,"getBlocks",{value:function(){return this[u]},writable:!1,configurable:!1,enumerable:!1}),A(t,"setExtend",{value:function(e){this[a]=e},writable:!1,configurable:!1,enumerable:!1}),A(t,"getExtend",{value:function(){return this[a]},writable:!1,configurable:!1,enumerable:!1}),A(t,"setLayout",{value:function(e){this[l]=e},writable:!1,configurable:!1,enumerable:!1}),A(t,"getLayout",{value:function(){return this[l]},writable:!1,configurable:!1,enumerable:!1}),A(t,"clone",{value:function(e){var n=[l,a,s];return!0===e&&n.push(u),x(this,n)},writable:!1,configurable:!1,enumerable:!1}),A(t,"extend",{value:function(e){this.setExtend(!0),this.setLayout(e)},writable:!1,configurable:!1,enumerable:!1}),A(t,"echo",{value:function(e){var n=this.getBuffer();[].slice.call(arguments).forEach(n)},writable:!1,configurable:!1,enumerable:!1}),A(t,"fn",{value:function(e){var n=this.getBuffer(),t=this;return function(){return n.backup(),r(e)&&e.apply(t,arguments),n.restore()}},writable:!1,configurable:!1,enumerable:!1}),A(t,"get",{value:function(e,n){var t=w(this,e,!0),r=t.shift(),i=t.pop();return k(r,i)?r[i]:n},writable:!1,configurable:!1,enumerable:!1}),A(t,"set",{value:function(e,n){var t=w(this,e,!1),r=t.shift(),i=t.pop();return this.getExtend()&&k(r,i)?r[i]:r[i]=n},writable:!1,configurable:!1,enumerable:!1}),A(t,"macro",{value:function(e,n){var t=this.getMacro(),r=this.fn(n),i=this;t[e]=function(){return i.echo(r.apply(void 0,arguments))}},writable:!1,configurable:!1,enumerable:!1}),A(t,"call",{value:function(e){var n=this.getMacro()[e],t=[].slice.call(arguments,1);if(r(n))return n.apply(n,t)},writable:!1,configurable:!1,enumerable:!1}),A(t,"block",{value:function(e,n){var t=this,r=this.getBlocks();if(r[e]=r[e]||[],r[e].push(this.fn(n)),!this.getExtend()){var i=Object.assign([],r[e]),o=function(){return i.shift()};this.echo(o()(function e(){var n=o();return n?function(){t.echo(n(e()))}:j}()))}},writable:!1,configurable:!1,enumerable:!1}),A(t,"include",{value:function(e,n,t){var r=!1===t?{}:this.clone(!0),i=y(r,n||{}),o=this.render(e,i);this.echo(o)},writable:!1,configurable:!1,enumerable:!1}),A(t,"use",{value:function(e,n){var t=this.require(e);this.echo(O(t,(function(e){var t=this.getMacro();E(e,(function(e,r){t[[n,r].join(".")]=e}))}),this))},writable:!1,configurable:!1,enumerable:!1}),A(t,"async",{value:function(e,n){this.echo(O(e,(function(e){return this.fn(n)(e)}),this))},writable:!1,configurable:!1,enumerable:!1}),A(t,"each",{value:function(e,n){i(e)&&(e=this.get(e,[])),E(e,n)},writable:!1,configurable:!1,enumerable:!1}),A(t,"element",{value:function(e,n,t){return W(e,n,t)},writable:!1,configurable:!1,enumerable:!1}),A(t,"el",{value:function(e,n,t){r(t)&&(t=this.fn(t)()),this.echo(O(t,(function(t){return this.element(e,n,t)}),this))},writable:!1,configurable:!1,enumerable:!1}),t))},this.configure(e)}var D={};var K=new function e(n){if(!1===m(this,e))return new e(n);var t={},i={};S(i,n||{});var o=new q(i),u=new T(i),c=new P,a=new $(i,c,u),l=function(e,n){var t=[n,n.getComponent(),n.getBuffer(),g];return i.globalHelpers.forEach((function(e){r(n[e])&&t.push(n[e].bind(n))})),a.get(e).then((function(e){return e.apply(n,t)}))},s=function e(n,t){var r=d(n,i.extension),u=o.create(t);return l(r,u).then((function(n){if(u.getExtend()){u.setExtend(!1);var t=u.getLayout(),r=u.clone();return e(t,r)}return n}))};return this.configure=function(e){return S(i,e=e||{}),o.configure(i,t),u.configure(i),c.configure(i),a.configure(i),i},this.render=function(e,n){return s(e,n)},this.helpers=function(e){o.helpers(y(t,e))},this.preload=function(e){return c.load(e||{})},this.create=function(n){return new e(n)},this.compile=function(e,n){return u.compile(e,n)},this.context=function(e){return o.create(e)},this.helpers({require:function(e){var n=d(e,i.extension),t=o.create({});return l(n,t).then((function(){return t.getMacro()}))},render:s}),this}({resolver:function(e,n){return new Promise((function(t,r){D.readFile(function(e,n){return(n=[e,n].join("/")).replace(/\/\//g,"/")}(e,n),(function(e,n){e?r(e):t(n.toString())}))}))}}),X=K.render,Y=K.context,z=K.compile,G=K.helpers,I=K.preload,Q=K.configure,V=K.create,Z=function(e){return function(t,u,c){r(u)&&(c=u,u={});var a=y({},(u=u||{}).settings),l=n(i,F.path,a.views),s=n(o,F.cache,a["view cache"]),f=y({},a["view options"]),h=D.relative(l,t);return f.path=l,f.cache=s,e.configure(f),e.render(h,u).then((function(e){c(null,e)})).catch((function(e){c(e)}))}}(K);e.__express=Z,e.compile=z,e.configure=Q,e.context=Y,e.create=V,e.helpers=G,e.preload=I,e.render=X}));
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.73",
6
+ "version": "0.0.75",
7
7
  "main": "dist/cjs/index.js",
8
8
  "module": "dist/esm/index.js",
9
9
  "browser": "dist/umd/browser.js",
@@ -37,7 +37,7 @@
37
37
  "devDependencies": {
38
38
  "@babel/core": "^7.20.12",
39
39
  "@babel/preset-env": "^7.20.2",
40
- "@kosatyi/rollup": "^0.0.19"
40
+ "@kosatyi/rollup": "^0.0.23"
41
41
  },
42
42
  "license": "MIT",
43
43
  "bugs": {