@kosatyi/ejs 0.0.87 → 0.0.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/browser.js +65 -5
- package/dist/cjs/element.js +1 -1
- package/dist/cjs/index.js +65 -5
- package/dist/cjs/worker.js +67 -5
- package/dist/esm/browser.js +60 -13
- package/dist/esm/element.js +1 -1
- package/dist/esm/index.js +60 -13
- package/dist/esm/worker.js +63 -15
- package/dist/umd/browser.js +65 -5
- package/dist/umd/browser.min.js +1 -1
- package/dist/umd/element.js +1 -1
- package/dist/umd/element.min.js +1 -1
- package/dist/umd/index.js +65 -5
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/worker.js +67 -5
- package/dist/umd/worker.min.js +1 -1
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -59,7 +59,7 @@ var symbols = function symbols(string) {
|
|
|
59
59
|
};
|
|
60
60
|
var safeValue = function safeValue(value, escape) {
|
|
61
61
|
var check = value;
|
|
62
|
-
return check == null ? '' : escape === true ? entities(check) : check;
|
|
62
|
+
return check == null ? '' : Boolean(escape) === true ? entities(check) : check;
|
|
63
63
|
};
|
|
64
64
|
var instanceOf = function instanceOf(object, instance) {
|
|
65
65
|
return Boolean(object instanceof instance);
|
|
@@ -429,31 +429,88 @@ var element = function element(tag, attrs, content) {
|
|
|
429
429
|
return result.join('');
|
|
430
430
|
};
|
|
431
431
|
|
|
432
|
+
/**
|
|
433
|
+
* @extends Error
|
|
434
|
+
* @property code
|
|
435
|
+
* @param {string} message
|
|
436
|
+
* @constructor
|
|
437
|
+
*/
|
|
432
438
|
function TemplateError(message) {
|
|
433
|
-
this.code = 1;
|
|
434
439
|
this.name = 'TemplateError';
|
|
435
440
|
this.message = message;
|
|
436
441
|
Error.call(this);
|
|
437
442
|
}
|
|
438
|
-
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
*
|
|
446
|
+
*/
|
|
447
|
+
Object.setPrototypeOf(TemplateError.prototype, Error.prototype);
|
|
448
|
+
Object.assign(TemplateError.prototype, {
|
|
449
|
+
code: 1
|
|
450
|
+
});
|
|
451
|
+
/**
|
|
452
|
+
*
|
|
453
|
+
* @return {number}
|
|
454
|
+
*/
|
|
455
|
+
TemplateError.prototype.getCode = function () {
|
|
456
|
+
return this.code;
|
|
457
|
+
};
|
|
458
|
+
/**
|
|
459
|
+
*
|
|
460
|
+
* @return {string}
|
|
461
|
+
*/
|
|
462
|
+
TemplateError.prototype.getMessage = function () {
|
|
463
|
+
return this.message;
|
|
464
|
+
};
|
|
465
|
+
/**
|
|
466
|
+
* @return {string}
|
|
467
|
+
*/
|
|
468
|
+
TemplateError.prototype.toString = function () {
|
|
469
|
+
return this.getMessage();
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* @extends TemplateError
|
|
474
|
+
* @param {string} message
|
|
475
|
+
* @constructor
|
|
476
|
+
*/
|
|
439
477
|
function TemplateNotFound(message) {
|
|
440
478
|
TemplateError.call(this);
|
|
441
|
-
this.code = 404;
|
|
442
479
|
this.name = 'TemplateNotFound';
|
|
443
480
|
this.message = message;
|
|
444
481
|
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
*
|
|
485
|
+
*/
|
|
445
486
|
Object.setPrototypeOf(TemplateNotFound.prototype, TemplateError.prototype);
|
|
487
|
+
Object.assign(TemplateNotFound.prototype, {
|
|
488
|
+
code: 404
|
|
489
|
+
});
|
|
490
|
+
/**
|
|
491
|
+
* @extends TemplateError
|
|
492
|
+
* @param {string} message
|
|
493
|
+
* @constructor
|
|
494
|
+
*/
|
|
446
495
|
function TemplateSyntaxError(message) {
|
|
447
496
|
TemplateError.call(this);
|
|
448
|
-
this.code = 500;
|
|
449
497
|
this.name = 'TemplateSyntaxError';
|
|
450
498
|
this.message = message;
|
|
451
499
|
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
*
|
|
503
|
+
*/
|
|
452
504
|
Object.setPrototypeOf(TemplateSyntaxError.prototype, TemplateError.prototype);
|
|
505
|
+
Object.assign(TemplateSyntaxError.prototype, {
|
|
506
|
+
code: 500
|
|
507
|
+
});
|
|
453
508
|
|
|
454
509
|
function resolve(list) {
|
|
455
510
|
return Promise.all(list || []).then(function (list) {
|
|
456
511
|
return list.join('');
|
|
512
|
+
})["catch"](function (e) {
|
|
513
|
+
return e;
|
|
457
514
|
});
|
|
458
515
|
}
|
|
459
516
|
function reject(error) {
|
|
@@ -885,6 +942,9 @@ var render = ejs.render,
|
|
|
885
942
|
configure = ejs.configure,
|
|
886
943
|
create = ejs.create;
|
|
887
944
|
|
|
945
|
+
exports.TemplateError = TemplateError;
|
|
946
|
+
exports.TemplateNotFound = TemplateNotFound;
|
|
947
|
+
exports.TemplateSyntaxError = TemplateSyntaxError;
|
|
888
948
|
exports.compile = compile;
|
|
889
949
|
exports.configure = configure;
|
|
890
950
|
exports.context = context;
|
package/dist/cjs/element.js
CHANGED
|
@@ -34,7 +34,7 @@ var entities = function entities() {
|
|
|
34
34
|
};
|
|
35
35
|
var safeValue = function safeValue(value, escape) {
|
|
36
36
|
var check = value;
|
|
37
|
-
return check == null ? '' : escape === true ? entities(check) : check;
|
|
37
|
+
return check == null ? '' : Boolean(escape) === true ? entities(check) : check;
|
|
38
38
|
};
|
|
39
39
|
var each = function each(object, callback) {
|
|
40
40
|
var prop;
|
package/dist/cjs/index.js
CHANGED
|
@@ -62,7 +62,7 @@ var symbols = function symbols(string) {
|
|
|
62
62
|
};
|
|
63
63
|
var safeValue = function safeValue(value, escape) {
|
|
64
64
|
var check = value;
|
|
65
|
-
return check == null ? '' : escape === true ? entities(check) : check;
|
|
65
|
+
return check == null ? '' : Boolean(escape) === true ? entities(check) : check;
|
|
66
66
|
};
|
|
67
67
|
var instanceOf = function instanceOf(object, instance) {
|
|
68
68
|
return Boolean(object instanceof instance);
|
|
@@ -432,31 +432,88 @@ var element = function element(tag, attrs, content) {
|
|
|
432
432
|
return result.join('');
|
|
433
433
|
};
|
|
434
434
|
|
|
435
|
+
/**
|
|
436
|
+
* @extends Error
|
|
437
|
+
* @property code
|
|
438
|
+
* @param {string} message
|
|
439
|
+
* @constructor
|
|
440
|
+
*/
|
|
435
441
|
function TemplateError(message) {
|
|
436
|
-
this.code = 1;
|
|
437
442
|
this.name = 'TemplateError';
|
|
438
443
|
this.message = message;
|
|
439
444
|
Error.call(this);
|
|
440
445
|
}
|
|
441
|
-
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
*
|
|
449
|
+
*/
|
|
450
|
+
Object.setPrototypeOf(TemplateError.prototype, Error.prototype);
|
|
451
|
+
Object.assign(TemplateError.prototype, {
|
|
452
|
+
code: 1
|
|
453
|
+
});
|
|
454
|
+
/**
|
|
455
|
+
*
|
|
456
|
+
* @return {number}
|
|
457
|
+
*/
|
|
458
|
+
TemplateError.prototype.getCode = function () {
|
|
459
|
+
return this.code;
|
|
460
|
+
};
|
|
461
|
+
/**
|
|
462
|
+
*
|
|
463
|
+
* @return {string}
|
|
464
|
+
*/
|
|
465
|
+
TemplateError.prototype.getMessage = function () {
|
|
466
|
+
return this.message;
|
|
467
|
+
};
|
|
468
|
+
/**
|
|
469
|
+
* @return {string}
|
|
470
|
+
*/
|
|
471
|
+
TemplateError.prototype.toString = function () {
|
|
472
|
+
return this.getMessage();
|
|
473
|
+
};
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* @extends TemplateError
|
|
477
|
+
* @param {string} message
|
|
478
|
+
* @constructor
|
|
479
|
+
*/
|
|
442
480
|
function TemplateNotFound(message) {
|
|
443
481
|
TemplateError.call(this);
|
|
444
|
-
this.code = 404;
|
|
445
482
|
this.name = 'TemplateNotFound';
|
|
446
483
|
this.message = message;
|
|
447
484
|
}
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
*
|
|
488
|
+
*/
|
|
448
489
|
Object.setPrototypeOf(TemplateNotFound.prototype, TemplateError.prototype);
|
|
490
|
+
Object.assign(TemplateNotFound.prototype, {
|
|
491
|
+
code: 404
|
|
492
|
+
});
|
|
493
|
+
/**
|
|
494
|
+
* @extends TemplateError
|
|
495
|
+
* @param {string} message
|
|
496
|
+
* @constructor
|
|
497
|
+
*/
|
|
449
498
|
function TemplateSyntaxError(message) {
|
|
450
499
|
TemplateError.call(this);
|
|
451
|
-
this.code = 500;
|
|
452
500
|
this.name = 'TemplateSyntaxError';
|
|
453
501
|
this.message = message;
|
|
454
502
|
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
*
|
|
506
|
+
*/
|
|
455
507
|
Object.setPrototypeOf(TemplateSyntaxError.prototype, TemplateError.prototype);
|
|
508
|
+
Object.assign(TemplateSyntaxError.prototype, {
|
|
509
|
+
code: 500
|
|
510
|
+
});
|
|
456
511
|
|
|
457
512
|
function resolve(list) {
|
|
458
513
|
return Promise.all(list || []).then(function (list) {
|
|
459
514
|
return list.join('');
|
|
515
|
+
})["catch"](function (e) {
|
|
516
|
+
return e;
|
|
460
517
|
});
|
|
461
518
|
}
|
|
462
519
|
function reject(error) {
|
|
@@ -921,6 +978,9 @@ var render = ejs.render,
|
|
|
921
978
|
create = ejs.create;
|
|
922
979
|
var __express = expressRenderer(ejs);
|
|
923
980
|
|
|
981
|
+
exports.TemplateError = TemplateError;
|
|
982
|
+
exports.TemplateNotFound = TemplateNotFound;
|
|
983
|
+
exports.TemplateSyntaxError = TemplateSyntaxError;
|
|
924
984
|
exports.__express = __express;
|
|
925
985
|
exports.compile = compile;
|
|
926
986
|
exports.configure = configure;
|
package/dist/cjs/worker.js
CHANGED
|
@@ -408,7 +408,7 @@ var symbols = function symbols(string) {
|
|
|
408
408
|
};
|
|
409
409
|
var safeValue = function safeValue(value, escape) {
|
|
410
410
|
var check = value;
|
|
411
|
-
return check == null ? '' : escape === true ? entities(check) : check;
|
|
411
|
+
return check == null ? '' : Boolean(escape) === true ? entities(check) : check;
|
|
412
412
|
};
|
|
413
413
|
var instanceOf = function instanceOf(object, instance) {
|
|
414
414
|
return Boolean(object instanceof instance);
|
|
@@ -750,31 +750,88 @@ var element = function element(tag, attrs, content) {
|
|
|
750
750
|
return result.join('');
|
|
751
751
|
};
|
|
752
752
|
|
|
753
|
+
/**
|
|
754
|
+
* @extends Error
|
|
755
|
+
* @property code
|
|
756
|
+
* @param {string} message
|
|
757
|
+
* @constructor
|
|
758
|
+
*/
|
|
753
759
|
function TemplateError(message) {
|
|
754
|
-
this.code = 1;
|
|
755
760
|
this.name = 'TemplateError';
|
|
756
761
|
this.message = message;
|
|
757
762
|
Error.call(this);
|
|
758
763
|
}
|
|
759
|
-
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
*
|
|
767
|
+
*/
|
|
768
|
+
Object.setPrototypeOf(TemplateError.prototype, Error.prototype);
|
|
769
|
+
Object.assign(TemplateError.prototype, {
|
|
770
|
+
code: 1
|
|
771
|
+
});
|
|
772
|
+
/**
|
|
773
|
+
*
|
|
774
|
+
* @return {number}
|
|
775
|
+
*/
|
|
776
|
+
TemplateError.prototype.getCode = function () {
|
|
777
|
+
return this.code;
|
|
778
|
+
};
|
|
779
|
+
/**
|
|
780
|
+
*
|
|
781
|
+
* @return {string}
|
|
782
|
+
*/
|
|
783
|
+
TemplateError.prototype.getMessage = function () {
|
|
784
|
+
return this.message;
|
|
785
|
+
};
|
|
786
|
+
/**
|
|
787
|
+
* @return {string}
|
|
788
|
+
*/
|
|
789
|
+
TemplateError.prototype.toString = function () {
|
|
790
|
+
return this.getMessage();
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* @extends TemplateError
|
|
795
|
+
* @param {string} message
|
|
796
|
+
* @constructor
|
|
797
|
+
*/
|
|
760
798
|
function TemplateNotFound(message) {
|
|
761
799
|
TemplateError.call(this);
|
|
762
|
-
this.code = 404;
|
|
763
800
|
this.name = 'TemplateNotFound';
|
|
764
801
|
this.message = message;
|
|
765
802
|
}
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
*
|
|
806
|
+
*/
|
|
766
807
|
Object.setPrototypeOf(TemplateNotFound.prototype, TemplateError.prototype);
|
|
808
|
+
Object.assign(TemplateNotFound.prototype, {
|
|
809
|
+
code: 404
|
|
810
|
+
});
|
|
811
|
+
/**
|
|
812
|
+
* @extends TemplateError
|
|
813
|
+
* @param {string} message
|
|
814
|
+
* @constructor
|
|
815
|
+
*/
|
|
767
816
|
function TemplateSyntaxError(message) {
|
|
768
817
|
TemplateError.call(this);
|
|
769
|
-
this.code = 500;
|
|
770
818
|
this.name = 'TemplateSyntaxError';
|
|
771
819
|
this.message = message;
|
|
772
820
|
}
|
|
821
|
+
|
|
822
|
+
/**
|
|
823
|
+
*
|
|
824
|
+
*/
|
|
773
825
|
Object.setPrototypeOf(TemplateSyntaxError.prototype, TemplateError.prototype);
|
|
826
|
+
Object.assign(TemplateSyntaxError.prototype, {
|
|
827
|
+
code: 500
|
|
828
|
+
});
|
|
774
829
|
|
|
775
830
|
function resolve(list) {
|
|
776
831
|
return Promise.all(list || []).then(function (list) {
|
|
777
832
|
return list.join('');
|
|
833
|
+
})["catch"](function (e) {
|
|
834
|
+
return e;
|
|
778
835
|
});
|
|
779
836
|
}
|
|
780
837
|
function reject(error) {
|
|
@@ -1213,6 +1270,7 @@ function setTemplates(list) {
|
|
|
1213
1270
|
/**
|
|
1214
1271
|
* @typedef {Object<string,any>} HonoContext
|
|
1215
1272
|
* @property {function(*):Promise<Response>} html
|
|
1273
|
+
* @property {function():Promise<Response>} notFound
|
|
1216
1274
|
* @property {function(name:string,data:{}):Promise<string>} render
|
|
1217
1275
|
* @property {function(name:string,data:{}):Promise<string>} ejs
|
|
1218
1276
|
* @property {ContextScope} data
|
|
@@ -1228,6 +1286,7 @@ function setRenderer(_ref) {
|
|
|
1228
1286
|
secure = _ref$secure === void 0 ? true : _ref$secure,
|
|
1229
1287
|
_ref$version = _ref.version,
|
|
1230
1288
|
version = _ref$version === void 0 ? '1.0' : _ref$version;
|
|
1289
|
+
_ref.errorHandler;
|
|
1231
1290
|
return /*#__PURE__*/function () {
|
|
1232
1291
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(c, next) {
|
|
1233
1292
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -1263,6 +1322,9 @@ var render = ejs.render,
|
|
|
1263
1322
|
configure = ejs.configure,
|
|
1264
1323
|
create = ejs.create;
|
|
1265
1324
|
|
|
1325
|
+
exports.TemplateError = TemplateError;
|
|
1326
|
+
exports.TemplateNotFound = TemplateNotFound;
|
|
1327
|
+
exports.TemplateSyntaxError = TemplateSyntaxError;
|
|
1266
1328
|
exports.compile = compile;
|
|
1267
1329
|
exports.configure = configure;
|
|
1268
1330
|
exports.context = context;
|
package/dist/esm/browser.js
CHANGED
|
@@ -57,7 +57,7 @@ const symbols = (string) => {
|
|
|
57
57
|
|
|
58
58
|
const safeValue = (value, escape) => {
|
|
59
59
|
const check = value;
|
|
60
|
-
return check == null ? '' : escape === true ? entities(check) : check
|
|
60
|
+
return check == null ? '' : Boolean(escape) === true ? entities(check) : check
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
const instanceOf = (object, instance) => {
|
|
@@ -503,34 +503,79 @@ const element = (tag, attrs, content) => {
|
|
|
503
503
|
return result.join('')
|
|
504
504
|
};
|
|
505
505
|
|
|
506
|
+
/**
|
|
507
|
+
* @extends Error
|
|
508
|
+
* @property code
|
|
509
|
+
* @param {string} message
|
|
510
|
+
* @constructor
|
|
511
|
+
*/
|
|
506
512
|
function TemplateError(message) {
|
|
507
|
-
this.code = 1;
|
|
508
513
|
this.name = 'TemplateError';
|
|
509
514
|
this.message = message;
|
|
510
515
|
Error.call(this);
|
|
511
516
|
}
|
|
512
|
-
Object.setPrototypeOf(TemplateNotFound.prototype, Error.prototype);
|
|
513
517
|
|
|
518
|
+
/**
|
|
519
|
+
*
|
|
520
|
+
*/
|
|
521
|
+
Object.setPrototypeOf(TemplateError.prototype, Error.prototype);
|
|
522
|
+
Object.assign(TemplateError.prototype, { code: 1 });
|
|
523
|
+
/**
|
|
524
|
+
*
|
|
525
|
+
* @return {number}
|
|
526
|
+
*/
|
|
527
|
+
TemplateError.prototype.getCode = function() {
|
|
528
|
+
return this.code
|
|
529
|
+
};
|
|
530
|
+
/**
|
|
531
|
+
*
|
|
532
|
+
* @return {string}
|
|
533
|
+
*/
|
|
534
|
+
TemplateError.prototype.getMessage = function() {
|
|
535
|
+
return this.message
|
|
536
|
+
};
|
|
537
|
+
/**
|
|
538
|
+
* @return {string}
|
|
539
|
+
*/
|
|
540
|
+
TemplateError.prototype.toString = function() {
|
|
541
|
+
return this.getMessage()
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* @extends TemplateError
|
|
546
|
+
* @param {string} message
|
|
547
|
+
* @constructor
|
|
548
|
+
*/
|
|
514
549
|
function TemplateNotFound(message) {
|
|
515
550
|
TemplateError.call(this);
|
|
516
|
-
this.code = 404;
|
|
517
551
|
this.name = 'TemplateNotFound';
|
|
518
552
|
this.message = message;
|
|
519
553
|
}
|
|
520
554
|
|
|
555
|
+
/**
|
|
556
|
+
*
|
|
557
|
+
*/
|
|
521
558
|
Object.setPrototypeOf(TemplateNotFound.prototype, TemplateError.prototype);
|
|
522
|
-
|
|
559
|
+
Object.assign(TemplateNotFound.prototype, { code: 404 });
|
|
560
|
+
/**
|
|
561
|
+
* @extends TemplateError
|
|
562
|
+
* @param {string} message
|
|
563
|
+
* @constructor
|
|
564
|
+
*/
|
|
523
565
|
function TemplateSyntaxError(message) {
|
|
524
566
|
TemplateError.call(this);
|
|
525
|
-
this.code = 500;
|
|
526
567
|
this.name = 'TemplateSyntaxError';
|
|
527
568
|
this.message = message;
|
|
528
569
|
}
|
|
529
570
|
|
|
571
|
+
/**
|
|
572
|
+
*
|
|
573
|
+
*/
|
|
530
574
|
Object.setPrototypeOf(TemplateSyntaxError.prototype, TemplateError.prototype);
|
|
575
|
+
Object.assign(TemplateSyntaxError.prototype, { code: 500 });
|
|
531
576
|
|
|
532
577
|
function resolve(list) {
|
|
533
|
-
return Promise.all(list || []).then((list) => list.join(''))
|
|
578
|
+
return Promise.all(list || []).then((list) => list.join('')).catch((e) => e)
|
|
534
579
|
}
|
|
535
580
|
|
|
536
581
|
function reject(error) {
|
|
@@ -540,25 +585,27 @@ function reject(error) {
|
|
|
540
585
|
function createBuffer() {
|
|
541
586
|
let store = [],
|
|
542
587
|
array = [];
|
|
588
|
+
|
|
543
589
|
function buffer(value) {
|
|
544
590
|
array.push(value);
|
|
545
591
|
}
|
|
546
|
-
|
|
592
|
+
|
|
593
|
+
buffer.start = function() {
|
|
547
594
|
array = [];
|
|
548
595
|
};
|
|
549
|
-
buffer.backup = function
|
|
596
|
+
buffer.backup = function() {
|
|
550
597
|
store.push(array.concat());
|
|
551
598
|
array = [];
|
|
552
599
|
};
|
|
553
|
-
buffer.restore = function
|
|
600
|
+
buffer.restore = function() {
|
|
554
601
|
const result = array.concat();
|
|
555
602
|
array = store.pop();
|
|
556
603
|
return resolve(result)
|
|
557
604
|
};
|
|
558
|
-
buffer.error = function
|
|
605
|
+
buffer.error = function(e) {
|
|
559
606
|
return reject(e)
|
|
560
607
|
};
|
|
561
|
-
buffer.end = function
|
|
608
|
+
buffer.end = function() {
|
|
562
609
|
return resolve(array)
|
|
563
610
|
};
|
|
564
611
|
return buffer
|
|
@@ -1004,4 +1051,4 @@ const ejs = new EJS({ resolver: httpRequest });
|
|
|
1004
1051
|
|
|
1005
1052
|
const { render, context, compile, helpers, preload, configure, create } = ejs;
|
|
1006
1053
|
|
|
1007
|
-
export { compile, configure, context, create, helpers, preload, render };
|
|
1054
|
+
export { TemplateError, TemplateNotFound, TemplateSyntaxError, compile, configure, context, create, helpers, preload, render };
|
package/dist/esm/element.js
CHANGED
|
@@ -38,7 +38,7 @@ const entities = (string = '') => {
|
|
|
38
38
|
|
|
39
39
|
const safeValue = (value, escape) => {
|
|
40
40
|
const check = value;
|
|
41
|
-
return check == null ? '' : escape === true ? entities(check) : check
|
|
41
|
+
return check == null ? '' : Boolean(escape) === true ? entities(check) : check
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
const each = (object, callback) => {
|
package/dist/esm/index.js
CHANGED
|
@@ -60,7 +60,7 @@ const symbols = (string) => {
|
|
|
60
60
|
|
|
61
61
|
const safeValue = (value, escape) => {
|
|
62
62
|
const check = value;
|
|
63
|
-
return check == null ? '' : escape === true ? entities(check) : check
|
|
63
|
+
return check == null ? '' : Boolean(escape) === true ? entities(check) : check
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
const instanceOf = (object, instance) => {
|
|
@@ -506,34 +506,79 @@ const element = (tag, attrs, content) => {
|
|
|
506
506
|
return result.join('')
|
|
507
507
|
};
|
|
508
508
|
|
|
509
|
+
/**
|
|
510
|
+
* @extends Error
|
|
511
|
+
* @property code
|
|
512
|
+
* @param {string} message
|
|
513
|
+
* @constructor
|
|
514
|
+
*/
|
|
509
515
|
function TemplateError(message) {
|
|
510
|
-
this.code = 1;
|
|
511
516
|
this.name = 'TemplateError';
|
|
512
517
|
this.message = message;
|
|
513
518
|
Error.call(this);
|
|
514
519
|
}
|
|
515
|
-
Object.setPrototypeOf(TemplateNotFound.prototype, Error.prototype);
|
|
516
520
|
|
|
521
|
+
/**
|
|
522
|
+
*
|
|
523
|
+
*/
|
|
524
|
+
Object.setPrototypeOf(TemplateError.prototype, Error.prototype);
|
|
525
|
+
Object.assign(TemplateError.prototype, { code: 1 });
|
|
526
|
+
/**
|
|
527
|
+
*
|
|
528
|
+
* @return {number}
|
|
529
|
+
*/
|
|
530
|
+
TemplateError.prototype.getCode = function() {
|
|
531
|
+
return this.code
|
|
532
|
+
};
|
|
533
|
+
/**
|
|
534
|
+
*
|
|
535
|
+
* @return {string}
|
|
536
|
+
*/
|
|
537
|
+
TemplateError.prototype.getMessage = function() {
|
|
538
|
+
return this.message
|
|
539
|
+
};
|
|
540
|
+
/**
|
|
541
|
+
* @return {string}
|
|
542
|
+
*/
|
|
543
|
+
TemplateError.prototype.toString = function() {
|
|
544
|
+
return this.getMessage()
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
/**
|
|
548
|
+
* @extends TemplateError
|
|
549
|
+
* @param {string} message
|
|
550
|
+
* @constructor
|
|
551
|
+
*/
|
|
517
552
|
function TemplateNotFound(message) {
|
|
518
553
|
TemplateError.call(this);
|
|
519
|
-
this.code = 404;
|
|
520
554
|
this.name = 'TemplateNotFound';
|
|
521
555
|
this.message = message;
|
|
522
556
|
}
|
|
523
557
|
|
|
558
|
+
/**
|
|
559
|
+
*
|
|
560
|
+
*/
|
|
524
561
|
Object.setPrototypeOf(TemplateNotFound.prototype, TemplateError.prototype);
|
|
525
|
-
|
|
562
|
+
Object.assign(TemplateNotFound.prototype, { code: 404 });
|
|
563
|
+
/**
|
|
564
|
+
* @extends TemplateError
|
|
565
|
+
* @param {string} message
|
|
566
|
+
* @constructor
|
|
567
|
+
*/
|
|
526
568
|
function TemplateSyntaxError(message) {
|
|
527
569
|
TemplateError.call(this);
|
|
528
|
-
this.code = 500;
|
|
529
570
|
this.name = 'TemplateSyntaxError';
|
|
530
571
|
this.message = message;
|
|
531
572
|
}
|
|
532
573
|
|
|
574
|
+
/**
|
|
575
|
+
*
|
|
576
|
+
*/
|
|
533
577
|
Object.setPrototypeOf(TemplateSyntaxError.prototype, TemplateError.prototype);
|
|
578
|
+
Object.assign(TemplateSyntaxError.prototype, { code: 500 });
|
|
534
579
|
|
|
535
580
|
function resolve(list) {
|
|
536
|
-
return Promise.all(list || []).then((list) => list.join(''))
|
|
581
|
+
return Promise.all(list || []).then((list) => list.join('')).catch((e) => e)
|
|
537
582
|
}
|
|
538
583
|
|
|
539
584
|
function reject(error) {
|
|
@@ -543,25 +588,27 @@ function reject(error) {
|
|
|
543
588
|
function createBuffer() {
|
|
544
589
|
let store = [],
|
|
545
590
|
array = [];
|
|
591
|
+
|
|
546
592
|
function buffer(value) {
|
|
547
593
|
array.push(value);
|
|
548
594
|
}
|
|
549
|
-
|
|
595
|
+
|
|
596
|
+
buffer.start = function() {
|
|
550
597
|
array = [];
|
|
551
598
|
};
|
|
552
|
-
buffer.backup = function
|
|
599
|
+
buffer.backup = function() {
|
|
553
600
|
store.push(array.concat());
|
|
554
601
|
array = [];
|
|
555
602
|
};
|
|
556
|
-
buffer.restore = function
|
|
603
|
+
buffer.restore = function() {
|
|
557
604
|
const result = array.concat();
|
|
558
605
|
array = store.pop();
|
|
559
606
|
return resolve(result)
|
|
560
607
|
};
|
|
561
|
-
buffer.error = function
|
|
608
|
+
buffer.error = function(e) {
|
|
562
609
|
return reject(e)
|
|
563
610
|
};
|
|
564
|
-
buffer.end = function
|
|
611
|
+
buffer.end = function() {
|
|
565
612
|
return resolve(array)
|
|
566
613
|
};
|
|
567
614
|
return buffer
|
|
@@ -1049,4 +1096,4 @@ const { render, context, compile, helpers, preload, configure, create } = ejs;
|
|
|
1049
1096
|
|
|
1050
1097
|
const __express = expressRenderer(ejs);
|
|
1051
1098
|
|
|
1052
|
-
export { __express, compile, configure, context, create, helpers, preload, render };
|
|
1099
|
+
export { TemplateError, TemplateNotFound, TemplateSyntaxError, __express, compile, configure, context, create, helpers, preload, render };
|