@kosatyi/ejs 0.0.64 → 0.0.66

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/umd/index.js CHANGED
@@ -65,7 +65,7 @@
65
65
  return check == null ? '' : escape === true ? entities(check) : check;
66
66
  };
67
67
  var instanceOf = function instanceOf(object, instance) {
68
- return object instanceof instance;
68
+ return Boolean(object instanceof instance);
69
69
  };
70
70
  var getPath = function getPath(context, name, strict) {
71
71
  var data = context;
@@ -94,11 +94,14 @@
94
94
  }
95
95
  return path;
96
96
  };
97
- var extend = function extend() {
98
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
99
- args[_key] = arguments[_key];
97
+
98
+ /**
99
+ * @type {<T extends {}, U, V, W,Y>(T,U,V,W,Y)=> T & U & V & W & Y}
100
+ */
101
+ var extend = function extend(target) {
102
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
103
+ args[_key - 1] = arguments[_key];
100
104
  }
101
- var target = args.shift();
102
105
  return args.filter(function (source) {
103
106
  return source;
104
107
  }).reduce(function (target, source) {
@@ -211,67 +214,54 @@
211
214
  extension: typeProp(isString, defaults.extension, config.extension, options.extension),
212
215
  withObject: typeProp(isBoolean, defaults.withObject, config.withObject, options.withObject),
213
216
  rmWhitespace: typeProp(isBoolean, defaults.rmWhitespace, config.rmWhitespace, options.rmWhitespace),
214
- cache: typeProp(isBoolean, defaults.watch, config.watch, options.watch),
217
+ cache: typeProp(isBoolean, defaults.cache, config.cache, options.cache),
215
218
  token: extend({}, defaults.token, config.token, options.token),
216
219
  vars: extend({}, defaults.vars, config.vars, options.vars)
217
220
  });
218
221
  };
219
222
 
220
- var resolvePath = function resolvePath(path, template) {
221
- template = [path, template].join('/');
222
- template = template.replace(/\/\//g, '/');
223
- return template;
224
- };
225
- var httpRequest = function httpRequest(path, template) {
226
- return fetch(resolvePath(path, template)).then(function (response) {
227
- return response.text();
228
- });
229
- };
230
- var fileSystem = function fileSystem(path$1, template) {
231
- return new Promise(function (resolve, reject) {
232
- path.readFile(resolvePath(path$1, template), function (error, data) {
233
- if (error) {
234
- reject(error);
235
- } else {
236
- resolve(data.toString());
237
- }
238
- });
239
- });
240
- };
241
- var fileResolver = function fileResolver(resolver) {
242
- return isFunction(resolver) ? resolver : isNode() ? fileSystem : httpRequest;
243
- };
244
- function Template(config, cache, compiler) {
245
- if (instanceOf(this, Template) === false) return new Template(config, cache, compiler);
246
- var template = {};
247
- var result = function result(template, content) {
248
- cache.set(template, content);
249
- return content;
223
+ var global = typeof globalThis !== 'undefined' ? globalThis : window || self;
224
+ function Cache(config) {
225
+ if (instanceOf(this, Cache) === false) return new Cache();
226
+ var cache = {
227
+ enabled: true,
228
+ list: {}
250
229
  };
251
- var resolve = function resolve(path) {
252
- return template.resolver(template.path, path);
230
+ this.configure = function (config) {
231
+ cache.enabled = config.cache;
232
+ if (isNode() === false) {
233
+ this.load(global[config["export"]]);
234
+ }
253
235
  };
254
- var compile = function compile(content, template) {
255
- if (isFunction(content)) {
256
- return content;
257
- } else {
258
- return compiler.compile(content, template);
236
+ this.clear = function () {
237
+ cache.list = {};
238
+ };
239
+ this.load = function (data) {
240
+ if (cache.enabled) {
241
+ extend(cache.list, data || {});
259
242
  }
243
+ return this;
260
244
  };
261
- this.configure = function (config) {
262
- template.path = config.path;
263
- template.cache = config.cache;
264
- template.resolver = fileResolver(config.resolver);
245
+ this.get = function (key) {
246
+ if (cache.enabled) {
247
+ return cache.list[key];
248
+ }
265
249
  };
266
- this.get = function (template) {
267
- if (cache.exist(template)) {
268
- return cache.resolve(template);
250
+ this.set = function (key, value) {
251
+ if (cache.enabled) {
252
+ cache.list[key] = value;
269
253
  }
270
- return result(template, resolve(template).then(function (content) {
271
- return result(template, compile(content, template));
272
- }));
254
+ return this;
255
+ };
256
+ this.resolve = function (key) {
257
+ return Promise.resolve(this.get(key));
258
+ };
259
+ this.remove = function (key) {
260
+ delete cache.list[key];
261
+ };
262
+ this.exist = function (key) {
263
+ return hasProp(cache.list, key);
273
264
  };
274
- this.configure(config);
275
265
  }
276
266
 
277
267
  var tagList = [{
@@ -369,46 +359,92 @@
369
359
  this.configure(config);
370
360
  }
371
361
 
372
- var global = typeof globalThis !== 'undefined' ? globalThis : window || self;
373
- function Cache(config) {
374
- if (instanceOf(this, Cache) === false) return new Cache();
375
- var cache = {
376
- enabled: true,
377
- list: {}
362
+ var resolvePath = function resolvePath(path, template) {
363
+ template = [path, template].join('/');
364
+ template = template.replace(/\/\//g, '/');
365
+ return template;
366
+ };
367
+ var httpRequest = function httpRequest(path, template) {
368
+ return fetch(resolvePath(path, template)).then(function (response) {
369
+ return response.text();
370
+ });
371
+ };
372
+ var fileSystem = function fileSystem(path$1, template) {
373
+ return new Promise(function (resolve, reject) {
374
+ path.readFile(resolvePath(path$1, template), function (error, data) {
375
+ if (error) {
376
+ reject(error);
377
+ } else {
378
+ resolve(data.toString());
379
+ }
380
+ });
381
+ });
382
+ };
383
+ var fileResolver = function fileResolver(resolver) {
384
+ return isFunction(resolver) ? resolver : isNode() ? fileSystem : httpRequest;
385
+ };
386
+ function Template(config, cache, compiler) {
387
+ if (instanceOf(this, Template) === false) return new Template(config, cache, compiler);
388
+ if (instanceOf(cache, Cache) === false) throw new TypeError('cache is not instance of Cache');
389
+ if (instanceOf(compiler, Compiler) === false) throw new TypeError('compiler is not instance of Compiler');
390
+ var template = {};
391
+ var result = function result(template, content) {
392
+ cache.set(template, content);
393
+ return content;
378
394
  };
379
- this.configure = function (config) {
380
- cache.list = {};
381
- cache.enabled = config.cache;
382
- if (isNode() === false) {
383
- this.load(global[config["export"]]);
384
- }
395
+ var resolve = function resolve(path) {
396
+ return template.resolver(template.path, path);
385
397
  };
386
- this.load = function (data) {
387
- if (cache.enabled) {
388
- extend(cache.list, data || {});
398
+ var compile = function compile(content, template) {
399
+ if (isFunction(content)) {
400
+ return content;
401
+ } else {
402
+ return compiler.compile(content, template);
389
403
  }
390
- return this;
391
404
  };
392
- this.get = function (key) {
393
- if (cache.enabled) {
394
- return cache.list[key];
395
- }
405
+ this.configure = function (config) {
406
+ template.path = config.path;
407
+ template.cache = config.cache;
408
+ template.resolver = fileResolver(config.resolver);
396
409
  };
397
- this.set = function (key, value) {
398
- if (cache.enabled) {
399
- cache.list[key] = value;
410
+ this.get = function (template) {
411
+ if (cache.exist(template)) {
412
+ return cache.resolve(template);
400
413
  }
401
- return this;
402
- };
403
- this.resolve = function (key) {
404
- return Promise.resolve(this.get(key));
405
- };
406
- this.remove = function (key) {
407
- delete cache.list[key];
408
- };
409
- this.exist = function (key) {
410
- return hasProp(cache.list, key);
414
+ return result(template, resolve(template).then(function (content) {
415
+ return result(template, compile(content, template));
416
+ }));
411
417
  };
418
+ this.configure(config);
419
+ }
420
+
421
+ function _defineProperty(obj, key, value) {
422
+ key = _toPropertyKey(key);
423
+ if (key in obj) {
424
+ Object.defineProperty(obj, key, {
425
+ value: value,
426
+ enumerable: true,
427
+ configurable: true,
428
+ writable: true
429
+ });
430
+ } else {
431
+ obj[key] = value;
432
+ }
433
+ return obj;
434
+ }
435
+ function _toPrimitive(input, hint) {
436
+ if (typeof input !== "object" || input === null) return input;
437
+ var prim = input[Symbol.toPrimitive];
438
+ if (prim !== undefined) {
439
+ var res = prim.call(input, hint || "default");
440
+ if (typeof res !== "object") return res;
441
+ throw new TypeError("@@toPrimitive must return a primitive value.");
442
+ }
443
+ return (hint === "string" ? String : Number)(input);
444
+ }
445
+ function _toPropertyKey(arg) {
446
+ var key = _toPrimitive(arg, "string");
447
+ return typeof key === "symbol" ? key : String(key);
412
448
  }
413
449
 
414
450
  function resolve(list) {
@@ -416,7 +452,7 @@
416
452
  return list.join('');
417
453
  });
418
454
  }
419
- var createBuffer = function createBuffer() {
455
+ function createBuffer() {
420
456
  var store = [],
421
457
  array = [];
422
458
  function buffer(value) {
@@ -441,11 +477,12 @@
441
477
  return resolve(array);
442
478
  };
443
479
  return buffer;
444
- };
480
+ }
445
481
 
446
482
  function Context(config) {
447
483
  if (instanceOf(this, Context) === false) return new Context(config);
448
484
  this.configure = function (config, methods) {
485
+ var _Object$definePropert;
449
486
  var _config$vars = config.vars,
450
487
  BLOCKS = _config$vars.BLOCKS,
451
488
  MACRO = _config$vars.MACRO,
@@ -458,6 +495,7 @@
458
495
  };
459
496
  this.helpers = function (methods) {
460
497
  extend(Scope.prototype, methods || {});
498
+ console.log('helpers', Scope.prototype);
461
499
  };
462
500
  function Scope(data) {
463
501
  this[BLOCKS] = {};
@@ -465,168 +503,270 @@
465
503
  extend(this, data || {});
466
504
  }
467
505
  Scope.prototype = extend({}, methods || {});
468
- Scope.method = Scope.define = function (name, value, writable, configurable, enumerable) {
469
- Object.defineProperty(Scope.prototype, name, {
470
- value: value,
471
- writable: writable || false,
472
- configurable: configurable || false,
473
- enumerable: enumerable || false
474
- });
475
- };
476
- Scope.define(BUFFER, createBuffer());
477
- Scope.define(BLOCKS, {}, true);
478
- Scope.define(MACRO, {}, true);
479
- Scope.define(LAYOUT, false, true);
480
- Scope.define(EXTEND, false, true);
481
- Scope.method('getMacro', function () {
482
- return this[MACRO];
483
- });
484
- Scope.method('getBuffer', function () {
485
- return this[BUFFER];
486
- });
487
- Scope.method('getComponent', function () {
488
- var context = this;
489
- if (COMPONENT in context) {
506
+ Object.defineProperties(Scope.prototype, (_Object$definePropert = {}, _defineProperty(_Object$definePropert, BUFFER, {
507
+ value: createBuffer(),
508
+ writable: true,
509
+ configurable: false,
510
+ enumerable: false
511
+ }), _defineProperty(_Object$definePropert, BLOCKS, {
512
+ value: {},
513
+ writable: true,
514
+ configurable: false,
515
+ enumerable: false
516
+ }), _defineProperty(_Object$definePropert, MACRO, {
517
+ value: {},
518
+ writable: true,
519
+ configurable: false,
520
+ enumerable: false
521
+ }), _defineProperty(_Object$definePropert, LAYOUT, {
522
+ value: false,
523
+ writable: true,
524
+ configurable: false,
525
+ enumerable: false
526
+ }), _defineProperty(_Object$definePropert, EXTEND, {
527
+ value: false,
528
+ writable: true,
529
+ configurable: false,
530
+ enumerable: false
531
+ }), _defineProperty(_Object$definePropert, "getMacro", {
532
+ value: function value() {
533
+ return this[MACRO];
534
+ },
535
+ writable: false,
536
+ configurable: false,
537
+ enumerable: false
538
+ }), _defineProperty(_Object$definePropert, "getBuffer", {
539
+ value: function value() {
540
+ return this[BUFFER];
541
+ },
542
+ writable: false,
543
+ configurable: false,
544
+ enumerable: false
545
+ }), _defineProperty(_Object$definePropert, "getComponent", {
546
+ value: function value() {
547
+ var context = this;
548
+ if (COMPONENT in context) {
549
+ return function () {
550
+ return context[COMPONENT].apply(context, arguments);
551
+ };
552
+ }
490
553
  return function () {
491
- return context[COMPONENT].apply(context, arguments);
554
+ console.log('%s function not defined', COMPONENT);
492
555
  };
493
- }
494
- return function () {
495
- console.log('%s function not defined', COMPONENT);
496
- };
497
- });
498
- Scope.method('getBlocks', function () {
499
- return this[BLOCKS];
500
- });
501
- Scope.method('setExtend', function (value) {
502
- this[EXTEND] = value;
503
- });
504
- Scope.method('getExtend', function () {
505
- return this[EXTEND];
506
- });
507
- Scope.method('setLayout', function (layout) {
508
- this[LAYOUT] = layout;
509
- });
510
- Scope.method('getLayout', function () {
511
- return this[LAYOUT];
512
- });
513
- Scope.method('clone', function (exclude_blocks) {
514
- var filter = [LAYOUT, EXTEND, BUFFER];
515
- if (exclude_blocks === true) {
516
- filter.push(BLOCKS);
517
- }
518
- return omit(this, filter);
519
- });
520
- Scope.method('extend', function (layout) {
521
- this.setExtend(true);
522
- this.setLayout(layout);
523
- });
524
- Scope.method('echo', function () {
525
- var buffer = this.getBuffer();
526
- var params = [].slice.call(arguments);
527
- params.forEach(buffer);
528
- });
529
- Scope.method('fn', function (callback) {
530
- var buffer = this.getBuffer();
531
- var context = this;
532
- return function () {
533
- buffer.backup();
534
- if (isFunction(callback)) {
535
- callback.apply(context, arguments);
556
+ },
557
+ writable: false,
558
+ configurable: false,
559
+ enumerable: false
560
+ }), _defineProperty(_Object$definePropert, "getBlocks", {
561
+ value: function value() {
562
+ return this[BLOCKS];
563
+ },
564
+ writable: false,
565
+ configurable: false,
566
+ enumerable: false
567
+ }), _defineProperty(_Object$definePropert, "setExtend", {
568
+ value: function value(_value) {
569
+ this[EXTEND] = _value;
570
+ },
571
+ writable: false,
572
+ configurable: false,
573
+ enumerable: false
574
+ }), _defineProperty(_Object$definePropert, "getExtend", {
575
+ value: function value() {
576
+ return this[EXTEND];
577
+ },
578
+ writable: false,
579
+ configurable: false,
580
+ enumerable: false
581
+ }), _defineProperty(_Object$definePropert, "setLayout", {
582
+ value: function value(layout) {
583
+ this[LAYOUT] = layout;
584
+ },
585
+ writable: false,
586
+ configurable: false,
587
+ enumerable: false
588
+ }), _defineProperty(_Object$definePropert, "getLayout", {
589
+ value: function value() {
590
+ return this[LAYOUT];
591
+ },
592
+ writable: false,
593
+ configurable: false,
594
+ enumerable: false
595
+ }), _defineProperty(_Object$definePropert, "clone", {
596
+ value: function value(exclude_blocks) {
597
+ var filter = [LAYOUT, EXTEND, BUFFER];
598
+ if (exclude_blocks === true) {
599
+ filter.push(BLOCKS);
536
600
  }
537
- return buffer.restore();
538
- };
539
- });
540
- Scope.method('get', function (name, defaults) {
541
- var path = getPath(this, name, true);
542
- var result = path.shift();
543
- var prop = path.pop();
544
- return hasProp(result, prop) ? result[prop] : defaults;
545
- });
546
- Scope.method('set', function (name, value) {
547
- var path = getPath(this, name, false);
548
- var result = path.shift();
549
- var prop = path.pop();
550
- if (this.getExtend() && hasProp(result, prop)) {
551
- return result[prop];
552
- }
553
- return result[prop] = value;
554
- });
555
- Scope.method('macro', function (name, callback) {
556
- var list = this.getMacro();
557
- var macro = this.fn(callback);
558
- var context = this;
559
- list[name] = function () {
560
- return context.echo(macro.apply(undefined, arguments));
561
- };
562
- });
563
- Scope.method('call', function (name) {
564
- var list = this.getMacro();
565
- var macro = list[name];
566
- var params = [].slice.call(arguments, 1);
567
- if (isFunction(macro)) {
568
- return macro.apply(macro, params);
569
- }
570
- });
571
- Scope.method('block', function (name, callback) {
572
- var _this = this;
573
- var blocks = this.getBlocks();
574
- blocks[name] = blocks[name] || [];
575
- blocks[name].push(this.fn(callback));
576
- if (this.getExtend()) return;
577
- var list = Object.assign([], blocks[name]);
578
- var current = function current() {
579
- return list.shift();
580
- };
581
- var next = function next() {
582
- var parent = current();
583
- if (parent) {
584
- return function () {
585
- _this.echo(parent(next()));
586
- };
587
- } else {
588
- return noop;
601
+ return omit(this, filter);
602
+ },
603
+ writable: false,
604
+ configurable: false,
605
+ enumerable: false
606
+ }), _defineProperty(_Object$definePropert, "extend", {
607
+ value: function value(layout) {
608
+ this.setExtend(true);
609
+ this.setLayout(layout);
610
+ },
611
+ writable: false,
612
+ configurable: false,
613
+ enumerable: false
614
+ }), _defineProperty(_Object$definePropert, "echo", {
615
+ value: function value(layout) {
616
+ var buffer = this.getBuffer();
617
+ var params = [].slice.call(arguments);
618
+ params.forEach(buffer);
619
+ },
620
+ writable: false,
621
+ configurable: false,
622
+ enumerable: false
623
+ }), _defineProperty(_Object$definePropert, "fn", {
624
+ value: function value(callback) {
625
+ var buffer = this.getBuffer();
626
+ var context = this;
627
+ return function () {
628
+ buffer.backup();
629
+ if (isFunction(callback)) {
630
+ callback.apply(context, arguments);
631
+ }
632
+ return buffer.restore();
633
+ };
634
+ },
635
+ writable: false,
636
+ configurable: false,
637
+ enumerable: false
638
+ }), _defineProperty(_Object$definePropert, "get", {
639
+ value: function value(name, defaults) {
640
+ var path = getPath(this, name, true);
641
+ var result = path.shift();
642
+ var prop = path.pop();
643
+ return hasProp(result, prop) ? result[prop] : defaults;
644
+ },
645
+ writable: false,
646
+ configurable: false,
647
+ enumerable: false
648
+ }), _defineProperty(_Object$definePropert, "set", {
649
+ value: function value(name, _value2) {
650
+ var path = getPath(this, name, false);
651
+ var result = path.shift();
652
+ var prop = path.pop();
653
+ if (this.getExtend() && hasProp(result, prop)) {
654
+ return result[prop];
589
655
  }
590
- };
591
- this.echo(current()(next()));
592
- });
593
- Scope.method('include', function (path, data, cx) {
594
- var context = cx === false ? {} : this.clone(true);
595
- var params = extend(context, data || {});
596
- var promise = this.render(path, params);
597
- this.echo(promise);
598
- });
599
- Scope.method('use', function (path, namespace) {
600
- var promise = this.require(path);
601
- this.echo(resolve$1(promise, function (exports) {
656
+ return result[prop] = _value2;
657
+ },
658
+ writable: false,
659
+ configurable: false,
660
+ enumerable: false
661
+ }), _defineProperty(_Object$definePropert, "macro", {
662
+ value: function value(name, callback) {
602
663
  var list = this.getMacro();
603
- each(exports, function (macro, name) {
604
- list[[namespace, name].join('.')] = macro;
605
- });
606
- }, this));
607
- });
608
- Scope.method('async', function (promise, callback) {
609
- this.echo(resolve$1(promise, function (data) {
610
- return this.fn(callback)(data);
611
- }, this));
612
- });
613
- Scope.method('node', function (tag, attr, content) {
614
- return element(tag, attr, content);
615
- });
616
- Scope.method('el', function (tag, attr, content) {
617
- if (isFunction(content)) {
618
- content = this.fn(content)();
619
- }
620
- this.echo(resolve$1(content, function (content) {
664
+ var macro = this.fn(callback);
665
+ var context = this;
666
+ list[name] = function () {
667
+ return context.echo(macro.apply(undefined, arguments));
668
+ };
669
+ },
670
+ writable: false,
671
+ configurable: false,
672
+ enumerable: false
673
+ }), _defineProperty(_Object$definePropert, "call", {
674
+ value: function value(name) {
675
+ var list = this.getMacro();
676
+ var macro = list[name];
677
+ var params = [].slice.call(arguments, 1);
678
+ if (isFunction(macro)) {
679
+ return macro.apply(macro, params);
680
+ }
681
+ },
682
+ writable: false,
683
+ configurable: false,
684
+ enumerable: false
685
+ }), _defineProperty(_Object$definePropert, "block", {
686
+ value: function value(name, callback) {
687
+ var _this = this;
688
+ var blocks = this.getBlocks();
689
+ blocks[name] = blocks[name] || [];
690
+ blocks[name].push(this.fn(callback));
691
+ if (this.getExtend()) return;
692
+ var list = Object.assign([], blocks[name]);
693
+ var current = function current() {
694
+ return list.shift();
695
+ };
696
+ var next = function next() {
697
+ var parent = current();
698
+ if (parent) {
699
+ return function () {
700
+ _this.echo(parent(next()));
701
+ };
702
+ } else {
703
+ return noop;
704
+ }
705
+ };
706
+ this.echo(current()(next()));
707
+ },
708
+ writable: false,
709
+ configurable: false,
710
+ enumerable: false
711
+ }), _defineProperty(_Object$definePropert, "include", {
712
+ value: function value(path, data, cx) {
713
+ var context = cx === false ? {} : this.clone(true);
714
+ var params = extend(context, data || {});
715
+ var promise = this.render(path, params);
716
+ this.echo(promise);
717
+ },
718
+ writable: false,
719
+ configurable: false,
720
+ enumerable: false
721
+ }), _defineProperty(_Object$definePropert, "use", {
722
+ value: function value(path, namespace) {
723
+ var promise = this.require(path);
724
+ this.echo(resolve$1(promise, function (exports) {
725
+ var list = this.getMacro();
726
+ each(exports, function (macro, name) {
727
+ list[[namespace, name].join('.')] = macro;
728
+ });
729
+ }, this));
730
+ },
731
+ writable: false,
732
+ configurable: false,
733
+ enumerable: false
734
+ }), _defineProperty(_Object$definePropert, "async", {
735
+ value: function value(promise, callback) {
736
+ this.echo(resolve$1(promise, function (data) {
737
+ return this.fn(callback)(data);
738
+ }, this));
739
+ },
740
+ writable: false,
741
+ configurable: false,
742
+ enumerable: false
743
+ }), _defineProperty(_Object$definePropert, "each", {
744
+ value: function value(object, callback) {
745
+ if (isString(object)) {
746
+ object = this.get(object, []);
747
+ }
748
+ each(object, callback);
749
+ },
750
+ writable: false,
751
+ configurable: false,
752
+ enumerable: false
753
+ }), _defineProperty(_Object$definePropert, "element", {
754
+ value: function value(tag, attr, content) {
621
755
  return element(tag, attr, content);
622
- }, this));
623
- });
624
- Scope.method('each', function (object, callback) {
625
- if (isString(object)) {
626
- object = this.get(object, []);
627
756
  }
628
- each(object, callback);
629
- });
757
+ }), _defineProperty(_Object$definePropert, "el", {
758
+ value: function value(tag, attr, content) {
759
+ if (isFunction(content)) {
760
+ content = this.fn(content)();
761
+ }
762
+ this.echo(resolve$1(content, function (content) {
763
+ return this.element(tag, attr, content);
764
+ }, this));
765
+ },
766
+ writable: false,
767
+ configurable: false,
768
+ enumerable: false
769
+ }), _Object$definePropert));
630
770
  };
631
771
  this.configure(config);
632
772
  }
@@ -678,7 +818,7 @@
678
818
  return render(name, data);
679
819
  };
680
820
  this.helpers = function (methods) {
681
- context.helpers(Object.assign(scope, methods || {}));
821
+ context.helpers(extend(scope, methods));
682
822
  };
683
823
  this.preload = function (list) {
684
824
  return cache.load(list || {});
@@ -696,6 +836,7 @@
696
836
  require: require,
697
837
  render: render
698
838
  });
839
+ return this;
699
840
  }
700
841
 
701
842
  var ejs = new EJS();
@@ -721,7 +862,7 @@
721
862
  viewOptions.path = viewPath;
722
863
  viewOptions.cache = viewCache;
723
864
  configure(viewOptions);
724
- return this.render(filename, options).then(function (content) {
865
+ return render(filename, options).then(function (content) {
725
866
  callback(null, content);
726
867
  })["catch"](function (error) {
727
868
  callback(error);