@kosatyi/ejs 0.0.100 → 0.0.102
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 -25
- package/dist/cjs/index.js +65 -25
- package/dist/cjs/worker.js +65 -25
- package/dist/esm/browser.js +110 -74
- package/dist/esm/index.js +110 -74
- package/dist/esm/worker.js +110 -74
- package/dist/umd/browser.js +65 -25
- package/dist/umd/browser.min.js +1 -1
- package/dist/umd/index.js +65 -25
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/worker.js +65 -25
- package/dist/umd/worker.min.js +1 -1
- package/package.json +1 -1
- package/types/ejs.d.ts +2 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -509,7 +509,7 @@ var Compiler = /*#__PURE__*/function () {
|
|
|
509
509
|
source = "".concat(BUFFER, ".start();").concat(source, "return ").concat(BUFFER, ".end();");
|
|
510
510
|
source += "\n//# sourceURL=".concat(path);
|
|
511
511
|
var result = null;
|
|
512
|
-
var params = [SCOPE,
|
|
512
|
+
var params = [SCOPE, COMPONENT, ELEMENT, BUFFER, SAFE].concat(GLOBALS);
|
|
513
513
|
try {
|
|
514
514
|
result = Function.apply(null, params.concat(source));
|
|
515
515
|
result.source = "(function(".concat(params.join(','), "){\n").concat(source, "\n});");
|
|
@@ -701,6 +701,7 @@ function createBuffer() {
|
|
|
701
701
|
return buffer;
|
|
702
702
|
}
|
|
703
703
|
|
|
704
|
+
var PARENT = Symbol('ContextScope.parentTemplate');
|
|
704
705
|
var createContextScope = function createContextScope(config, methods) {
|
|
705
706
|
var _config$vars = config.vars,
|
|
706
707
|
BLOCKS = _config$vars.BLOCKS,
|
|
@@ -712,12 +713,18 @@ var createContextScope = function createContextScope(config, methods) {
|
|
|
712
713
|
SCOPE = _config$vars.SCOPE,
|
|
713
714
|
COMPONENT = _config$vars.COMPONENT,
|
|
714
715
|
ELEMENT = _config$vars.ELEMENT;
|
|
716
|
+
/**
|
|
717
|
+
*
|
|
718
|
+
* @type {symbol}
|
|
719
|
+
*/
|
|
720
|
+
|
|
715
721
|
/**
|
|
716
722
|
* @name ContextScope
|
|
717
723
|
* @param data
|
|
718
724
|
* @constructor
|
|
719
725
|
*/
|
|
720
726
|
function ContextScope(data) {
|
|
727
|
+
this[PARENT] = null;
|
|
721
728
|
this[BLOCKS] = {};
|
|
722
729
|
this[MACRO] = {};
|
|
723
730
|
Object.assign(this, omit(data, [SCOPE, BUFFER, SAFE, COMPONENT, ELEMENT]));
|
|
@@ -742,7 +749,24 @@ var createContextScope = function createContextScope(config, methods) {
|
|
|
742
749
|
value: false,
|
|
743
750
|
writable: true
|
|
744
751
|
});
|
|
752
|
+
Object.defineProperty(ContextScope.prototype, PARENT, {
|
|
753
|
+
value: null,
|
|
754
|
+
writable: true
|
|
755
|
+
});
|
|
745
756
|
Object.defineProperties(ContextScope.prototype, {
|
|
757
|
+
/** @type {function} */
|
|
758
|
+
setParentTemplate: {
|
|
759
|
+
value: function value(_value) {
|
|
760
|
+
this[PARENT] = _value;
|
|
761
|
+
return this;
|
|
762
|
+
}
|
|
763
|
+
},
|
|
764
|
+
/** @type {function} */
|
|
765
|
+
getParentTemplate: {
|
|
766
|
+
value: function value() {
|
|
767
|
+
return this[PARENT];
|
|
768
|
+
}
|
|
769
|
+
},
|
|
746
770
|
/** @type {function} */
|
|
747
771
|
useSafeValue: {
|
|
748
772
|
get: function get() {
|
|
@@ -793,8 +817,9 @@ var createContextScope = function createContextScope(config, methods) {
|
|
|
793
817
|
},
|
|
794
818
|
/** @type {function} */
|
|
795
819
|
setExtend: {
|
|
796
|
-
value: function value(
|
|
797
|
-
this[EXTEND] =
|
|
820
|
+
value: function value(_value2) {
|
|
821
|
+
this[EXTEND] = _value2;
|
|
822
|
+
return this;
|
|
798
823
|
}
|
|
799
824
|
},
|
|
800
825
|
/** @type {function} */
|
|
@@ -807,6 +832,7 @@ var createContextScope = function createContextScope(config, methods) {
|
|
|
807
832
|
setLayout: {
|
|
808
833
|
value: function value(layout) {
|
|
809
834
|
this[LAYOUT] = layout;
|
|
835
|
+
return this;
|
|
810
836
|
}
|
|
811
837
|
},
|
|
812
838
|
/** @type {function} */
|
|
@@ -945,14 +971,14 @@ var createContextScope = function createContextScope(config, methods) {
|
|
|
945
971
|
},
|
|
946
972
|
/** @type {function} */
|
|
947
973
|
set: {
|
|
948
|
-
value: function value(name,
|
|
974
|
+
value: function value(name, _value3) {
|
|
949
975
|
var path = getPath(this, name, false);
|
|
950
976
|
var result = path.shift();
|
|
951
977
|
var prop = path.pop();
|
|
952
|
-
if (this.
|
|
978
|
+
if (this.getParentTemplate() && hasProp(result, prop)) {
|
|
953
979
|
return result[prop];
|
|
954
980
|
}
|
|
955
|
-
return result[prop] =
|
|
981
|
+
return result[prop] = _value3;
|
|
956
982
|
}
|
|
957
983
|
},
|
|
958
984
|
/** @type {function} */
|
|
@@ -1048,21 +1074,43 @@ var EJS = /*#__PURE__*/function () {
|
|
|
1048
1074
|
_classPrivateFieldGet2(_template, this).configure(_classPrivateFieldGet2(_config, this));
|
|
1049
1075
|
return _classPrivateFieldGet2(_config, this);
|
|
1050
1076
|
}
|
|
1077
|
+
}, {
|
|
1078
|
+
key: "filePath",
|
|
1079
|
+
value: function filePath(name) {
|
|
1080
|
+
return ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1081
|
+
}
|
|
1082
|
+
}, {
|
|
1083
|
+
key: "require",
|
|
1084
|
+
value: function require(name) {
|
|
1085
|
+
var scope = this.context({});
|
|
1086
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(function () {
|
|
1087
|
+
return scope.getMacro();
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1051
1090
|
}, {
|
|
1052
1091
|
key: "render",
|
|
1053
1092
|
value: function render(name, data) {
|
|
1054
|
-
var _this = this;
|
|
1055
|
-
var filepath = ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1056
1093
|
var scope = this.context(data);
|
|
1057
|
-
return _assertClassBrand(_EJS_brand, this, _output).call(this,
|
|
1094
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(this.outputContent(name, scope));
|
|
1095
|
+
}
|
|
1096
|
+
}, {
|
|
1097
|
+
key: "outputContent",
|
|
1098
|
+
value: function outputContent(name, scope) {
|
|
1099
|
+
var _this = this;
|
|
1100
|
+
return function (content) {
|
|
1058
1101
|
if (scope.getExtend()) {
|
|
1059
1102
|
scope.setExtend(false);
|
|
1060
|
-
|
|
1061
|
-
var _data = scope.clone();
|
|
1062
|
-
return _this.render(layout, _data);
|
|
1103
|
+
return _this.renderLayout(scope.getLayout(), scope, name);
|
|
1063
1104
|
}
|
|
1064
1105
|
return content;
|
|
1065
|
-
}
|
|
1106
|
+
};
|
|
1107
|
+
}
|
|
1108
|
+
}, {
|
|
1109
|
+
key: "renderLayout",
|
|
1110
|
+
value: function renderLayout(name, data, parent) {
|
|
1111
|
+
var scope = this.context(data);
|
|
1112
|
+
if (parent) scope.setParentTemplate(parent);
|
|
1113
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(this.outputContent(name, scope));
|
|
1066
1114
|
}
|
|
1067
1115
|
}, {
|
|
1068
1116
|
key: "helpers",
|
|
@@ -1089,27 +1137,19 @@ var EJS = /*#__PURE__*/function () {
|
|
|
1089
1137
|
value: function create(options) {
|
|
1090
1138
|
return new this.constructor(options);
|
|
1091
1139
|
}
|
|
1092
|
-
}, {
|
|
1093
|
-
key: "require",
|
|
1094
|
-
value: function require(name) {
|
|
1095
|
-
var filepath = ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1096
|
-
var scope = this.context({});
|
|
1097
|
-
return _assertClassBrand(_EJS_brand, this, _output).call(this, filepath, scope).then(function () {
|
|
1098
|
-
return scope.getMacro();
|
|
1099
|
-
});
|
|
1100
|
-
}
|
|
1101
1140
|
}]);
|
|
1102
1141
|
}();
|
|
1103
1142
|
function _output(path, scope) {
|
|
1104
1143
|
var _classPrivateFieldGet2$1 = _classPrivateFieldGet2(_config, this),
|
|
1105
1144
|
globalHelpers = _classPrivateFieldGet2$1.globalHelpers;
|
|
1106
|
-
var params = [scope, scope.
|
|
1145
|
+
var params = [scope, scope.useComponent, scope.useElement, scope.getBuffer(), scope.useSafeValue];
|
|
1146
|
+
var globals = globalHelpers.filter(function (name) {
|
|
1107
1147
|
return isFunction(scope[name]);
|
|
1108
1148
|
}).map(function (name) {
|
|
1109
1149
|
return scope[name].bind(scope);
|
|
1110
|
-
})
|
|
1150
|
+
});
|
|
1111
1151
|
return _classPrivateFieldGet2(_template, this).get(path).then(function (callback) {
|
|
1112
|
-
return callback.apply(scope, params);
|
|
1152
|
+
return callback.apply(scope, params.concat(globals));
|
|
1113
1153
|
});
|
|
1114
1154
|
}
|
|
1115
1155
|
|
package/dist/cjs/index.js
CHANGED
|
@@ -512,7 +512,7 @@ var Compiler = /*#__PURE__*/function () {
|
|
|
512
512
|
source = "".concat(BUFFER, ".start();").concat(source, "return ").concat(BUFFER, ".end();");
|
|
513
513
|
source += "\n//# sourceURL=".concat(path);
|
|
514
514
|
var result = null;
|
|
515
|
-
var params = [SCOPE,
|
|
515
|
+
var params = [SCOPE, COMPONENT, ELEMENT, BUFFER, SAFE].concat(GLOBALS);
|
|
516
516
|
try {
|
|
517
517
|
result = Function.apply(null, params.concat(source));
|
|
518
518
|
result.source = "(function(".concat(params.join(','), "){\n").concat(source, "\n});");
|
|
@@ -704,6 +704,7 @@ function createBuffer() {
|
|
|
704
704
|
return buffer;
|
|
705
705
|
}
|
|
706
706
|
|
|
707
|
+
var PARENT = Symbol('ContextScope.parentTemplate');
|
|
707
708
|
var createContextScope = function createContextScope(config, methods) {
|
|
708
709
|
var _config$vars = config.vars,
|
|
709
710
|
BLOCKS = _config$vars.BLOCKS,
|
|
@@ -715,12 +716,18 @@ var createContextScope = function createContextScope(config, methods) {
|
|
|
715
716
|
SCOPE = _config$vars.SCOPE,
|
|
716
717
|
COMPONENT = _config$vars.COMPONENT,
|
|
717
718
|
ELEMENT = _config$vars.ELEMENT;
|
|
719
|
+
/**
|
|
720
|
+
*
|
|
721
|
+
* @type {symbol}
|
|
722
|
+
*/
|
|
723
|
+
|
|
718
724
|
/**
|
|
719
725
|
* @name ContextScope
|
|
720
726
|
* @param data
|
|
721
727
|
* @constructor
|
|
722
728
|
*/
|
|
723
729
|
function ContextScope(data) {
|
|
730
|
+
this[PARENT] = null;
|
|
724
731
|
this[BLOCKS] = {};
|
|
725
732
|
this[MACRO] = {};
|
|
726
733
|
Object.assign(this, omit(data, [SCOPE, BUFFER, SAFE, COMPONENT, ELEMENT]));
|
|
@@ -745,7 +752,24 @@ var createContextScope = function createContextScope(config, methods) {
|
|
|
745
752
|
value: false,
|
|
746
753
|
writable: true
|
|
747
754
|
});
|
|
755
|
+
Object.defineProperty(ContextScope.prototype, PARENT, {
|
|
756
|
+
value: null,
|
|
757
|
+
writable: true
|
|
758
|
+
});
|
|
748
759
|
Object.defineProperties(ContextScope.prototype, {
|
|
760
|
+
/** @type {function} */
|
|
761
|
+
setParentTemplate: {
|
|
762
|
+
value: function value(_value) {
|
|
763
|
+
this[PARENT] = _value;
|
|
764
|
+
return this;
|
|
765
|
+
}
|
|
766
|
+
},
|
|
767
|
+
/** @type {function} */
|
|
768
|
+
getParentTemplate: {
|
|
769
|
+
value: function value() {
|
|
770
|
+
return this[PARENT];
|
|
771
|
+
}
|
|
772
|
+
},
|
|
749
773
|
/** @type {function} */
|
|
750
774
|
useSafeValue: {
|
|
751
775
|
get: function get() {
|
|
@@ -796,8 +820,9 @@ var createContextScope = function createContextScope(config, methods) {
|
|
|
796
820
|
},
|
|
797
821
|
/** @type {function} */
|
|
798
822
|
setExtend: {
|
|
799
|
-
value: function value(
|
|
800
|
-
this[EXTEND] =
|
|
823
|
+
value: function value(_value2) {
|
|
824
|
+
this[EXTEND] = _value2;
|
|
825
|
+
return this;
|
|
801
826
|
}
|
|
802
827
|
},
|
|
803
828
|
/** @type {function} */
|
|
@@ -810,6 +835,7 @@ var createContextScope = function createContextScope(config, methods) {
|
|
|
810
835
|
setLayout: {
|
|
811
836
|
value: function value(layout) {
|
|
812
837
|
this[LAYOUT] = layout;
|
|
838
|
+
return this;
|
|
813
839
|
}
|
|
814
840
|
},
|
|
815
841
|
/** @type {function} */
|
|
@@ -948,14 +974,14 @@ var createContextScope = function createContextScope(config, methods) {
|
|
|
948
974
|
},
|
|
949
975
|
/** @type {function} */
|
|
950
976
|
set: {
|
|
951
|
-
value: function value(name,
|
|
977
|
+
value: function value(name, _value3) {
|
|
952
978
|
var path = getPath(this, name, false);
|
|
953
979
|
var result = path.shift();
|
|
954
980
|
var prop = path.pop();
|
|
955
|
-
if (this.
|
|
981
|
+
if (this.getParentTemplate() && hasProp(result, prop)) {
|
|
956
982
|
return result[prop];
|
|
957
983
|
}
|
|
958
|
-
return result[prop] =
|
|
984
|
+
return result[prop] = _value3;
|
|
959
985
|
}
|
|
960
986
|
},
|
|
961
987
|
/** @type {function} */
|
|
@@ -1051,21 +1077,43 @@ var EJS = /*#__PURE__*/function () {
|
|
|
1051
1077
|
_classPrivateFieldGet2(_template, this).configure(_classPrivateFieldGet2(_config, this));
|
|
1052
1078
|
return _classPrivateFieldGet2(_config, this);
|
|
1053
1079
|
}
|
|
1080
|
+
}, {
|
|
1081
|
+
key: "filePath",
|
|
1082
|
+
value: function filePath(name) {
|
|
1083
|
+
return ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1084
|
+
}
|
|
1085
|
+
}, {
|
|
1086
|
+
key: "require",
|
|
1087
|
+
value: function require(name) {
|
|
1088
|
+
var scope = this.context({});
|
|
1089
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(function () {
|
|
1090
|
+
return scope.getMacro();
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1054
1093
|
}, {
|
|
1055
1094
|
key: "render",
|
|
1056
1095
|
value: function render(name, data) {
|
|
1057
|
-
var _this = this;
|
|
1058
|
-
var filepath = ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1059
1096
|
var scope = this.context(data);
|
|
1060
|
-
return _assertClassBrand(_EJS_brand, this, _output).call(this,
|
|
1097
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(this.outputContent(name, scope));
|
|
1098
|
+
}
|
|
1099
|
+
}, {
|
|
1100
|
+
key: "outputContent",
|
|
1101
|
+
value: function outputContent(name, scope) {
|
|
1102
|
+
var _this = this;
|
|
1103
|
+
return function (content) {
|
|
1061
1104
|
if (scope.getExtend()) {
|
|
1062
1105
|
scope.setExtend(false);
|
|
1063
|
-
|
|
1064
|
-
var _data = scope.clone();
|
|
1065
|
-
return _this.render(layout, _data);
|
|
1106
|
+
return _this.renderLayout(scope.getLayout(), scope, name);
|
|
1066
1107
|
}
|
|
1067
1108
|
return content;
|
|
1068
|
-
}
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
}, {
|
|
1112
|
+
key: "renderLayout",
|
|
1113
|
+
value: function renderLayout(name, data, parent) {
|
|
1114
|
+
var scope = this.context(data);
|
|
1115
|
+
if (parent) scope.setParentTemplate(parent);
|
|
1116
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(this.outputContent(name, scope));
|
|
1069
1117
|
}
|
|
1070
1118
|
}, {
|
|
1071
1119
|
key: "helpers",
|
|
@@ -1092,27 +1140,19 @@ var EJS = /*#__PURE__*/function () {
|
|
|
1092
1140
|
value: function create(options) {
|
|
1093
1141
|
return new this.constructor(options);
|
|
1094
1142
|
}
|
|
1095
|
-
}, {
|
|
1096
|
-
key: "require",
|
|
1097
|
-
value: function require(name) {
|
|
1098
|
-
var filepath = ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1099
|
-
var scope = this.context({});
|
|
1100
|
-
return _assertClassBrand(_EJS_brand, this, _output).call(this, filepath, scope).then(function () {
|
|
1101
|
-
return scope.getMacro();
|
|
1102
|
-
});
|
|
1103
|
-
}
|
|
1104
1143
|
}]);
|
|
1105
1144
|
}();
|
|
1106
1145
|
function _output(path, scope) {
|
|
1107
1146
|
var _classPrivateFieldGet2$1 = _classPrivateFieldGet2(_config, this),
|
|
1108
1147
|
globalHelpers = _classPrivateFieldGet2$1.globalHelpers;
|
|
1109
|
-
var params = [scope, scope.
|
|
1148
|
+
var params = [scope, scope.useComponent, scope.useElement, scope.getBuffer(), scope.useSafeValue];
|
|
1149
|
+
var globals = globalHelpers.filter(function (name) {
|
|
1110
1150
|
return isFunction(scope[name]);
|
|
1111
1151
|
}).map(function (name) {
|
|
1112
1152
|
return scope[name].bind(scope);
|
|
1113
|
-
})
|
|
1153
|
+
});
|
|
1114
1154
|
return _classPrivateFieldGet2(_template, this).get(path).then(function (callback) {
|
|
1115
|
-
return callback.apply(scope, params);
|
|
1155
|
+
return callback.apply(scope, params.concat(globals));
|
|
1116
1156
|
});
|
|
1117
1157
|
}
|
|
1118
1158
|
|
package/dist/cjs/worker.js
CHANGED
|
@@ -830,7 +830,7 @@ var Compiler = /*#__PURE__*/function () {
|
|
|
830
830
|
source = "".concat(BUFFER, ".start();").concat(source, "return ").concat(BUFFER, ".end();");
|
|
831
831
|
source += "\n//# sourceURL=".concat(path);
|
|
832
832
|
var result = null;
|
|
833
|
-
var params = [SCOPE,
|
|
833
|
+
var params = [SCOPE, COMPONENT, ELEMENT, BUFFER, SAFE].concat(GLOBALS);
|
|
834
834
|
try {
|
|
835
835
|
result = Function.apply(null, params.concat(source));
|
|
836
836
|
result.source = "(function(".concat(params.join(','), "){\n").concat(source, "\n});");
|
|
@@ -1022,6 +1022,7 @@ function createBuffer() {
|
|
|
1022
1022
|
return buffer;
|
|
1023
1023
|
}
|
|
1024
1024
|
|
|
1025
|
+
var PARENT = Symbol('ContextScope.parentTemplate');
|
|
1025
1026
|
var createContextScope = function createContextScope(config, methods) {
|
|
1026
1027
|
var _config$vars = config.vars,
|
|
1027
1028
|
BLOCKS = _config$vars.BLOCKS,
|
|
@@ -1033,12 +1034,18 @@ var createContextScope = function createContextScope(config, methods) {
|
|
|
1033
1034
|
SCOPE = _config$vars.SCOPE,
|
|
1034
1035
|
COMPONENT = _config$vars.COMPONENT,
|
|
1035
1036
|
ELEMENT = _config$vars.ELEMENT;
|
|
1037
|
+
/**
|
|
1038
|
+
*
|
|
1039
|
+
* @type {symbol}
|
|
1040
|
+
*/
|
|
1041
|
+
|
|
1036
1042
|
/**
|
|
1037
1043
|
* @name ContextScope
|
|
1038
1044
|
* @param data
|
|
1039
1045
|
* @constructor
|
|
1040
1046
|
*/
|
|
1041
1047
|
function ContextScope(data) {
|
|
1048
|
+
this[PARENT] = null;
|
|
1042
1049
|
this[BLOCKS] = {};
|
|
1043
1050
|
this[MACRO] = {};
|
|
1044
1051
|
Object.assign(this, omit(data, [SCOPE, BUFFER, SAFE, COMPONENT, ELEMENT]));
|
|
@@ -1063,7 +1070,24 @@ var createContextScope = function createContextScope(config, methods) {
|
|
|
1063
1070
|
value: false,
|
|
1064
1071
|
writable: true
|
|
1065
1072
|
});
|
|
1073
|
+
Object.defineProperty(ContextScope.prototype, PARENT, {
|
|
1074
|
+
value: null,
|
|
1075
|
+
writable: true
|
|
1076
|
+
});
|
|
1066
1077
|
Object.defineProperties(ContextScope.prototype, {
|
|
1078
|
+
/** @type {function} */
|
|
1079
|
+
setParentTemplate: {
|
|
1080
|
+
value: function value(_value) {
|
|
1081
|
+
this[PARENT] = _value;
|
|
1082
|
+
return this;
|
|
1083
|
+
}
|
|
1084
|
+
},
|
|
1085
|
+
/** @type {function} */
|
|
1086
|
+
getParentTemplate: {
|
|
1087
|
+
value: function value() {
|
|
1088
|
+
return this[PARENT];
|
|
1089
|
+
}
|
|
1090
|
+
},
|
|
1067
1091
|
/** @type {function} */
|
|
1068
1092
|
useSafeValue: {
|
|
1069
1093
|
get: function get() {
|
|
@@ -1114,8 +1138,9 @@ var createContextScope = function createContextScope(config, methods) {
|
|
|
1114
1138
|
},
|
|
1115
1139
|
/** @type {function} */
|
|
1116
1140
|
setExtend: {
|
|
1117
|
-
value: function value(
|
|
1118
|
-
this[EXTEND] =
|
|
1141
|
+
value: function value(_value2) {
|
|
1142
|
+
this[EXTEND] = _value2;
|
|
1143
|
+
return this;
|
|
1119
1144
|
}
|
|
1120
1145
|
},
|
|
1121
1146
|
/** @type {function} */
|
|
@@ -1128,6 +1153,7 @@ var createContextScope = function createContextScope(config, methods) {
|
|
|
1128
1153
|
setLayout: {
|
|
1129
1154
|
value: function value(layout) {
|
|
1130
1155
|
this[LAYOUT] = layout;
|
|
1156
|
+
return this;
|
|
1131
1157
|
}
|
|
1132
1158
|
},
|
|
1133
1159
|
/** @type {function} */
|
|
@@ -1266,14 +1292,14 @@ var createContextScope = function createContextScope(config, methods) {
|
|
|
1266
1292
|
},
|
|
1267
1293
|
/** @type {function} */
|
|
1268
1294
|
set: {
|
|
1269
|
-
value: function value(name,
|
|
1295
|
+
value: function value(name, _value3) {
|
|
1270
1296
|
var path = getPath(this, name, false);
|
|
1271
1297
|
var result = path.shift();
|
|
1272
1298
|
var prop = path.pop();
|
|
1273
|
-
if (this.
|
|
1299
|
+
if (this.getParentTemplate() && hasProp(result, prop)) {
|
|
1274
1300
|
return result[prop];
|
|
1275
1301
|
}
|
|
1276
|
-
return result[prop] =
|
|
1302
|
+
return result[prop] = _value3;
|
|
1277
1303
|
}
|
|
1278
1304
|
},
|
|
1279
1305
|
/** @type {function} */
|
|
@@ -1369,21 +1395,43 @@ var EJS = /*#__PURE__*/function () {
|
|
|
1369
1395
|
_classPrivateFieldGet2(_template, this).configure(_classPrivateFieldGet2(_config, this));
|
|
1370
1396
|
return _classPrivateFieldGet2(_config, this);
|
|
1371
1397
|
}
|
|
1398
|
+
}, {
|
|
1399
|
+
key: "filePath",
|
|
1400
|
+
value: function filePath(name) {
|
|
1401
|
+
return ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1402
|
+
}
|
|
1403
|
+
}, {
|
|
1404
|
+
key: "require",
|
|
1405
|
+
value: function require(name) {
|
|
1406
|
+
var scope = this.context({});
|
|
1407
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(function () {
|
|
1408
|
+
return scope.getMacro();
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1372
1411
|
}, {
|
|
1373
1412
|
key: "render",
|
|
1374
1413
|
value: function render(name, data) {
|
|
1375
|
-
var _this = this;
|
|
1376
|
-
var filepath = ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1377
1414
|
var scope = this.context(data);
|
|
1378
|
-
return _assertClassBrand(_EJS_brand, this, _output).call(this,
|
|
1415
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(this.outputContent(name, scope));
|
|
1416
|
+
}
|
|
1417
|
+
}, {
|
|
1418
|
+
key: "outputContent",
|
|
1419
|
+
value: function outputContent(name, scope) {
|
|
1420
|
+
var _this = this;
|
|
1421
|
+
return function (content) {
|
|
1379
1422
|
if (scope.getExtend()) {
|
|
1380
1423
|
scope.setExtend(false);
|
|
1381
|
-
|
|
1382
|
-
var _data = scope.clone();
|
|
1383
|
-
return _this.render(layout, _data);
|
|
1424
|
+
return _this.renderLayout(scope.getLayout(), scope, name);
|
|
1384
1425
|
}
|
|
1385
1426
|
return content;
|
|
1386
|
-
}
|
|
1427
|
+
};
|
|
1428
|
+
}
|
|
1429
|
+
}, {
|
|
1430
|
+
key: "renderLayout",
|
|
1431
|
+
value: function renderLayout(name, data, parent) {
|
|
1432
|
+
var scope = this.context(data);
|
|
1433
|
+
if (parent) scope.setParentTemplate(parent);
|
|
1434
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(this.outputContent(name, scope));
|
|
1387
1435
|
}
|
|
1388
1436
|
}, {
|
|
1389
1437
|
key: "helpers",
|
|
@@ -1410,27 +1458,19 @@ var EJS = /*#__PURE__*/function () {
|
|
|
1410
1458
|
value: function create(options) {
|
|
1411
1459
|
return new this.constructor(options);
|
|
1412
1460
|
}
|
|
1413
|
-
}, {
|
|
1414
|
-
key: "require",
|
|
1415
|
-
value: function require(name) {
|
|
1416
|
-
var filepath = ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1417
|
-
var scope = this.context({});
|
|
1418
|
-
return _assertClassBrand(_EJS_brand, this, _output).call(this, filepath, scope).then(function () {
|
|
1419
|
-
return scope.getMacro();
|
|
1420
|
-
});
|
|
1421
|
-
}
|
|
1422
1461
|
}]);
|
|
1423
1462
|
}();
|
|
1424
1463
|
function _output(path, scope) {
|
|
1425
1464
|
var _classPrivateFieldGet2$1 = _classPrivateFieldGet2(_config, this),
|
|
1426
1465
|
globalHelpers = _classPrivateFieldGet2$1.globalHelpers;
|
|
1427
|
-
var params = [scope, scope.
|
|
1466
|
+
var params = [scope, scope.useComponent, scope.useElement, scope.getBuffer(), scope.useSafeValue];
|
|
1467
|
+
var globals = globalHelpers.filter(function (name) {
|
|
1428
1468
|
return isFunction(scope[name]);
|
|
1429
1469
|
}).map(function (name) {
|
|
1430
1470
|
return scope[name].bind(scope);
|
|
1431
|
-
})
|
|
1471
|
+
});
|
|
1432
1472
|
return _classPrivateFieldGet2(_template, this).get(path).then(function (callback) {
|
|
1433
|
-
return callback.apply(scope, params);
|
|
1473
|
+
return callback.apply(scope, params.concat(globals));
|
|
1434
1474
|
});
|
|
1435
1475
|
}
|
|
1436
1476
|
|