@kosatyi/ejs 0.0.99 → 0.0.101
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 +292 -196
- package/dist/cjs/index.js +292 -196
- package/dist/cjs/worker.js +292 -196
- package/dist/esm/browser.js +113 -84
- package/dist/esm/index.js +113 -84
- package/dist/esm/worker.js +113 -84
- package/dist/umd/browser.js +292 -196
- package/dist/umd/browser.min.js +1 -1
- package/dist/umd/index.js +292 -196
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/worker.js +292 -196
- package/dist/umd/worker.min.js +1 -1
- package/package.json +1 -1
package/dist/umd/index.js
CHANGED
|
@@ -705,8 +705,8 @@
|
|
|
705
705
|
return buffer;
|
|
706
706
|
}
|
|
707
707
|
|
|
708
|
+
var PARENT = Symbol('ContextScope.parentTemplate');
|
|
708
709
|
var createContextScope = function createContextScope(config, methods) {
|
|
709
|
-
var _Object$definePropert;
|
|
710
710
|
var _config$vars = config.vars,
|
|
711
711
|
BLOCKS = _config$vars.BLOCKS,
|
|
712
712
|
MACRO = _config$vars.MACRO,
|
|
@@ -717,217 +717,300 @@
|
|
|
717
717
|
SCOPE = _config$vars.SCOPE,
|
|
718
718
|
COMPONENT = _config$vars.COMPONENT,
|
|
719
719
|
ELEMENT = _config$vars.ELEMENT;
|
|
720
|
+
/**
|
|
721
|
+
*
|
|
722
|
+
* @type {symbol}
|
|
723
|
+
*/
|
|
724
|
+
|
|
720
725
|
/**
|
|
721
726
|
* @name ContextScope
|
|
722
727
|
* @param data
|
|
723
728
|
* @constructor
|
|
724
729
|
*/
|
|
725
730
|
function ContextScope(data) {
|
|
731
|
+
this[PARENT] = null;
|
|
726
732
|
this[BLOCKS] = {};
|
|
727
733
|
this[MACRO] = {};
|
|
728
734
|
Object.assign(this, omit(data, [SCOPE, BUFFER, SAFE, COMPONENT, ELEMENT]));
|
|
729
735
|
}
|
|
730
736
|
Object.assign(ContextScope.prototype, methods);
|
|
731
|
-
Object.
|
|
737
|
+
Object.defineProperty(ContextScope.prototype, BUFFER, {
|
|
732
738
|
value: createBuffer()
|
|
733
|
-
})
|
|
739
|
+
});
|
|
740
|
+
Object.defineProperty(ContextScope.prototype, BLOCKS, {
|
|
734
741
|
value: {},
|
|
735
742
|
writable: true
|
|
736
|
-
})
|
|
743
|
+
});
|
|
744
|
+
Object.defineProperty(ContextScope.prototype, MACRO, {
|
|
737
745
|
value: {},
|
|
738
746
|
writable: true
|
|
739
|
-
})
|
|
747
|
+
});
|
|
748
|
+
Object.defineProperty(ContextScope.prototype, LAYOUT, {
|
|
740
749
|
value: false,
|
|
741
750
|
writable: true
|
|
742
|
-
})
|
|
751
|
+
});
|
|
752
|
+
Object.defineProperty(ContextScope.prototype, EXTEND, {
|
|
743
753
|
value: false,
|
|
744
754
|
writable: true
|
|
745
|
-
})
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
})
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
};
|
|
755
|
+
});
|
|
756
|
+
Object.defineProperty(ContextScope.prototype, PARENT, {
|
|
757
|
+
value: null,
|
|
758
|
+
writable: true
|
|
759
|
+
});
|
|
760
|
+
Object.defineProperties(ContextScope.prototype, {
|
|
761
|
+
/** @type {function} */
|
|
762
|
+
setParentTemplate: {
|
|
763
|
+
value: function value(_value) {
|
|
764
|
+
this[PARENT] = _value;
|
|
765
|
+
return this;
|
|
757
766
|
}
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
return this[
|
|
763
|
-
} else {
|
|
764
|
-
return function () {
|
|
765
|
-
throw new Error("".concat(ELEMENT, " must be a function"));
|
|
766
|
-
};
|
|
767
|
+
},
|
|
768
|
+
/** @type {function} */
|
|
769
|
+
getParentTemplate: {
|
|
770
|
+
value: function value() {
|
|
771
|
+
return this[PARENT];
|
|
767
772
|
}
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
}), "getBuffer", {
|
|
774
|
-
value: function value() {
|
|
775
|
-
return this[BUFFER];
|
|
776
|
-
}
|
|
777
|
-
}), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "getBlocks", {
|
|
778
|
-
value: function value() {
|
|
779
|
-
return this[BLOCKS];
|
|
780
|
-
}
|
|
781
|
-
}), "setExtend", {
|
|
782
|
-
value: function value(_value) {
|
|
783
|
-
this[EXTEND] = _value;
|
|
784
|
-
}
|
|
785
|
-
}), "getExtend", {
|
|
786
|
-
value: function value() {
|
|
787
|
-
return this[EXTEND];
|
|
788
|
-
}
|
|
789
|
-
}), "setLayout", {
|
|
790
|
-
value: function value(layout) {
|
|
791
|
-
this[LAYOUT] = layout;
|
|
792
|
-
}
|
|
793
|
-
}), "getLayout", {
|
|
794
|
-
value: function value() {
|
|
795
|
-
return this[LAYOUT];
|
|
796
|
-
}
|
|
797
|
-
}), "clone", {
|
|
798
|
-
value: function value(exclude_blocks) {
|
|
799
|
-
var filter = [LAYOUT, EXTEND, BUFFER];
|
|
800
|
-
if (exclude_blocks === true) {
|
|
801
|
-
filter.push(BLOCKS);
|
|
773
|
+
},
|
|
774
|
+
/** @type {function} */
|
|
775
|
+
useSafeValue: {
|
|
776
|
+
get: function get() {
|
|
777
|
+
return safeValue;
|
|
802
778
|
}
|
|
803
|
-
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
var params = [].slice.call(arguments);
|
|
814
|
-
params.forEach(buffer);
|
|
815
|
-
}
|
|
816
|
-
}), "fn", {
|
|
817
|
-
value: function value(callback) {
|
|
818
|
-
var buffer = this.getBuffer();
|
|
819
|
-
var context = this;
|
|
820
|
-
return function () {
|
|
821
|
-
if (isFunction(callback)) {
|
|
822
|
-
buffer.backup();
|
|
823
|
-
buffer(callback.apply(context, arguments));
|
|
824
|
-
return buffer.restore();
|
|
779
|
+
},
|
|
780
|
+
/** @type {function} */
|
|
781
|
+
useComponent: {
|
|
782
|
+
get: function get() {
|
|
783
|
+
if (isFunction(this[COMPONENT])) {
|
|
784
|
+
return this[COMPONENT].bind(this);
|
|
785
|
+
} else {
|
|
786
|
+
return function () {
|
|
787
|
+
throw new Error("".concat(COMPONENT, " must be a function"));
|
|
788
|
+
};
|
|
825
789
|
}
|
|
826
|
-
};
|
|
827
|
-
}
|
|
828
|
-
}), "macro", {
|
|
829
|
-
value: function value(name, callback) {
|
|
830
|
-
var list = this.getMacro();
|
|
831
|
-
var macro = this.fn(callback);
|
|
832
|
-
var context = this;
|
|
833
|
-
list[name] = function () {
|
|
834
|
-
return context.echo(macro.apply(undefined, arguments));
|
|
835
|
-
};
|
|
836
|
-
}
|
|
837
|
-
}), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "call", {
|
|
838
|
-
value: function value(name) {
|
|
839
|
-
var list = this.getMacro();
|
|
840
|
-
var macro = list[name];
|
|
841
|
-
var params = [].slice.call(arguments, 1);
|
|
842
|
-
if (isFunction(macro)) {
|
|
843
|
-
return macro.apply(macro, params);
|
|
844
790
|
}
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
if (this.getExtend()) return;
|
|
853
|
-
var list = Object.assign([], blocks[name]);
|
|
854
|
-
var current = function current() {
|
|
855
|
-
return list.shift();
|
|
856
|
-
};
|
|
857
|
-
var _next = function next() {
|
|
858
|
-
var parent = current();
|
|
859
|
-
if (parent) {
|
|
791
|
+
},
|
|
792
|
+
/** @type {function} */
|
|
793
|
+
useElement: {
|
|
794
|
+
get: function get() {
|
|
795
|
+
if (isFunction(this[ELEMENT])) {
|
|
796
|
+
return this[ELEMENT].bind(this);
|
|
797
|
+
} else {
|
|
860
798
|
return function () {
|
|
861
|
-
|
|
799
|
+
throw new Error("".concat(ELEMENT, " must be a function"));
|
|
862
800
|
};
|
|
863
|
-
} else {
|
|
864
|
-
return noop;
|
|
865
801
|
}
|
|
866
|
-
};
|
|
867
|
-
this.echo(current()(_next()));
|
|
868
|
-
}
|
|
869
|
-
}), "hasBlock", {
|
|
870
|
-
value: function value(name) {
|
|
871
|
-
return this.getBlocks().hasOwnProperty(name);
|
|
872
|
-
}
|
|
873
|
-
}), "include", {
|
|
874
|
-
value: function value(path, data, cx) {
|
|
875
|
-
var context = cx === false ? {} : this.clone(true);
|
|
876
|
-
var params = extend(context, data || {});
|
|
877
|
-
var promise = this.render(path, params);
|
|
878
|
-
this.echo(promise);
|
|
879
|
-
}
|
|
880
|
-
}), "use", {
|
|
881
|
-
value: function value(path, namespace) {
|
|
882
|
-
var _this2 = this;
|
|
883
|
-
this.echo(Promise.resolve(this.require(path)).then(function (exports) {
|
|
884
|
-
var list = _this2.getMacro();
|
|
885
|
-
each(exports, function (macro, name) {
|
|
886
|
-
list[[namespace, name].join('.')] = macro;
|
|
887
|
-
});
|
|
888
|
-
}));
|
|
889
|
-
}
|
|
890
|
-
}), "async", {
|
|
891
|
-
value: function value(promise, callback) {
|
|
892
|
-
this.echo(Promise.resolve(promise).then(callback));
|
|
893
|
-
}
|
|
894
|
-
}), "get", {
|
|
895
|
-
value: function value(name, defaults) {
|
|
896
|
-
var path = getPath(this, name, true);
|
|
897
|
-
var result = path.shift();
|
|
898
|
-
var prop = path.pop();
|
|
899
|
-
return hasProp(result, prop) ? result[prop] : defaults;
|
|
900
|
-
}
|
|
901
|
-
}), "set", {
|
|
902
|
-
value: function value(name, _value2) {
|
|
903
|
-
var path = getPath(this, name, false);
|
|
904
|
-
var result = path.shift();
|
|
905
|
-
var prop = path.pop();
|
|
906
|
-
if (this.getExtend() && hasProp(result, prop)) {
|
|
907
|
-
return result[prop];
|
|
908
802
|
}
|
|
909
|
-
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
object = this.get(object, []);
|
|
803
|
+
},
|
|
804
|
+
/** @type {()=>this[MACRO]} */
|
|
805
|
+
getMacro: {
|
|
806
|
+
value: function value() {
|
|
807
|
+
return this[MACRO];
|
|
915
808
|
}
|
|
916
|
-
each(object, callback);
|
|
917
809
|
},
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
return element(tag, attr, content);
|
|
924
|
-
}));
|
|
810
|
+
/** @type {function} */
|
|
811
|
+
getBuffer: {
|
|
812
|
+
value: function value() {
|
|
813
|
+
return this[BUFFER];
|
|
814
|
+
}
|
|
925
815
|
},
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
816
|
+
/** @type {function} */
|
|
817
|
+
getBlocks: {
|
|
818
|
+
value: function value() {
|
|
819
|
+
return this[BLOCKS];
|
|
820
|
+
}
|
|
821
|
+
},
|
|
822
|
+
/** @type {function} */
|
|
823
|
+
setExtend: {
|
|
824
|
+
value: function value(_value2) {
|
|
825
|
+
this[EXTEND] = _value2;
|
|
826
|
+
return this;
|
|
827
|
+
}
|
|
828
|
+
},
|
|
829
|
+
/** @type {function} */
|
|
830
|
+
getExtend: {
|
|
831
|
+
value: function value() {
|
|
832
|
+
return this[EXTEND];
|
|
833
|
+
}
|
|
834
|
+
},
|
|
835
|
+
/** @type {function} */
|
|
836
|
+
setLayout: {
|
|
837
|
+
value: function value(layout) {
|
|
838
|
+
this[LAYOUT] = layout;
|
|
839
|
+
return this;
|
|
840
|
+
}
|
|
841
|
+
},
|
|
842
|
+
/** @type {function} */
|
|
843
|
+
getLayout: {
|
|
844
|
+
value: function value() {
|
|
845
|
+
return this[LAYOUT];
|
|
846
|
+
}
|
|
847
|
+
},
|
|
848
|
+
/** @type {function} */
|
|
849
|
+
clone: {
|
|
850
|
+
value: function value(exclude_blocks) {
|
|
851
|
+
var filter = [LAYOUT, EXTEND, BUFFER];
|
|
852
|
+
if (exclude_blocks === true) {
|
|
853
|
+
filter.push(BLOCKS);
|
|
854
|
+
}
|
|
855
|
+
return omit(this, filter);
|
|
856
|
+
}
|
|
857
|
+
},
|
|
858
|
+
/** @type {function} */
|
|
859
|
+
extend: {
|
|
860
|
+
value: function value(layout) {
|
|
861
|
+
this.setExtend(true);
|
|
862
|
+
this.setLayout(layout);
|
|
863
|
+
}
|
|
864
|
+
},
|
|
865
|
+
/** @type {function} */
|
|
866
|
+
echo: {
|
|
867
|
+
value: function value(layout) {
|
|
868
|
+
var buffer = this.getBuffer();
|
|
869
|
+
var params = [].slice.call(arguments);
|
|
870
|
+
params.forEach(buffer);
|
|
871
|
+
}
|
|
872
|
+
},
|
|
873
|
+
/** @type {function} */
|
|
874
|
+
fn: {
|
|
875
|
+
value: function value(callback) {
|
|
876
|
+
var buffer = this.getBuffer();
|
|
877
|
+
var context = this;
|
|
878
|
+
return function () {
|
|
879
|
+
if (isFunction(callback)) {
|
|
880
|
+
buffer.backup();
|
|
881
|
+
buffer(callback.apply(context, arguments));
|
|
882
|
+
return buffer.restore();
|
|
883
|
+
}
|
|
884
|
+
};
|
|
885
|
+
}
|
|
886
|
+
},
|
|
887
|
+
/** @type {function} */
|
|
888
|
+
macro: {
|
|
889
|
+
value: function value(name, callback) {
|
|
890
|
+
var list = this.getMacro();
|
|
891
|
+
var macro = this.fn(callback);
|
|
892
|
+
var context = this;
|
|
893
|
+
list[name] = function () {
|
|
894
|
+
return context.echo(macro.apply(undefined, arguments));
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
},
|
|
898
|
+
/** @type {function} */
|
|
899
|
+
call: {
|
|
900
|
+
value: function value(name) {
|
|
901
|
+
var list = this.getMacro();
|
|
902
|
+
var macro = list[name];
|
|
903
|
+
var params = [].slice.call(arguments, 1);
|
|
904
|
+
if (isFunction(macro)) {
|
|
905
|
+
return macro.apply(macro, params);
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
},
|
|
909
|
+
/** @type {function} */
|
|
910
|
+
block: {
|
|
911
|
+
value: function value(name, callback) {
|
|
912
|
+
var _this = this;
|
|
913
|
+
var blocks = this.getBlocks();
|
|
914
|
+
blocks[name] = blocks[name] || [];
|
|
915
|
+
blocks[name].push(this.fn(callback));
|
|
916
|
+
if (this.getExtend()) return;
|
|
917
|
+
var list = Object.assign([], blocks[name]);
|
|
918
|
+
var current = function current() {
|
|
919
|
+
return list.shift();
|
|
920
|
+
};
|
|
921
|
+
var _next = function next() {
|
|
922
|
+
var parent = current();
|
|
923
|
+
if (parent) {
|
|
924
|
+
return function () {
|
|
925
|
+
_this.echo(parent(_next()));
|
|
926
|
+
};
|
|
927
|
+
} else {
|
|
928
|
+
return noop;
|
|
929
|
+
}
|
|
930
|
+
};
|
|
931
|
+
this.echo(current()(_next()));
|
|
932
|
+
}
|
|
933
|
+
},
|
|
934
|
+
/** @type {function} */
|
|
935
|
+
hasBlock: {
|
|
936
|
+
value: function value(name) {
|
|
937
|
+
return this.getBlocks().hasOwnProperty(name);
|
|
938
|
+
}
|
|
939
|
+
},
|
|
940
|
+
/** @type {function} */
|
|
941
|
+
include: {
|
|
942
|
+
value: function value(path, data, cx) {
|
|
943
|
+
var context = cx === false ? {} : this.clone(true);
|
|
944
|
+
var params = extend(context, data || {});
|
|
945
|
+
var promise = this.render(path, params);
|
|
946
|
+
this.echo(promise);
|
|
947
|
+
}
|
|
948
|
+
},
|
|
949
|
+
/** @type {function} */
|
|
950
|
+
use: {
|
|
951
|
+
value: function value(path, namespace) {
|
|
952
|
+
var _this2 = this;
|
|
953
|
+
this.echo(Promise.resolve(this.require(path)).then(function (exports) {
|
|
954
|
+
var list = _this2.getMacro();
|
|
955
|
+
each(exports, function (macro, name) {
|
|
956
|
+
list[[namespace, name].join('.')] = macro;
|
|
957
|
+
});
|
|
958
|
+
}));
|
|
959
|
+
}
|
|
960
|
+
},
|
|
961
|
+
/** @type {function} */
|
|
962
|
+
async: {
|
|
963
|
+
value: function value(promise, callback) {
|
|
964
|
+
this.echo(Promise.resolve(promise).then(callback));
|
|
965
|
+
}
|
|
966
|
+
},
|
|
967
|
+
/** @type {function} */
|
|
968
|
+
get: {
|
|
969
|
+
value: function value(name, defaults) {
|
|
970
|
+
var path = getPath(this, name, true);
|
|
971
|
+
var result = path.shift();
|
|
972
|
+
var prop = path.pop();
|
|
973
|
+
return hasProp(result, prop) ? result[prop] : defaults;
|
|
974
|
+
}
|
|
975
|
+
},
|
|
976
|
+
/** @type {function} */
|
|
977
|
+
set: {
|
|
978
|
+
value: function value(name, _value3) {
|
|
979
|
+
var path = getPath(this, name, false);
|
|
980
|
+
var result = path.shift();
|
|
981
|
+
var prop = path.pop();
|
|
982
|
+
if (this.getParentTemplate() && hasProp(result, prop)) {
|
|
983
|
+
return result[prop];
|
|
984
|
+
}
|
|
985
|
+
return result[prop] = _value3;
|
|
986
|
+
}
|
|
987
|
+
},
|
|
988
|
+
/** @type {function} */
|
|
989
|
+
each: {
|
|
990
|
+
value: function value(object, callback) {
|
|
991
|
+
if (isString(object)) {
|
|
992
|
+
object = this.get(object, []);
|
|
993
|
+
}
|
|
994
|
+
each(object, callback);
|
|
995
|
+
},
|
|
996
|
+
writable: true
|
|
997
|
+
},
|
|
998
|
+
/** @type {function} */
|
|
999
|
+
el: {
|
|
1000
|
+
value: function value(tag, attr, content) {
|
|
1001
|
+
content = isFunction(content) ? this.fn(content)() : content;
|
|
1002
|
+
this.echo(Promise.resolve(content).then(function (content) {
|
|
1003
|
+
return element(tag, attr, content);
|
|
1004
|
+
}));
|
|
1005
|
+
},
|
|
1006
|
+
writable: true
|
|
1007
|
+
},
|
|
1008
|
+
/** @type {function} */
|
|
1009
|
+
ui: {
|
|
1010
|
+
value: function value(layout) {},
|
|
1011
|
+
writable: true
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
931
1014
|
return ContextScope;
|
|
932
1015
|
};
|
|
933
1016
|
var _scope = /*#__PURE__*/new WeakMap();
|
|
@@ -995,21 +1078,43 @@
|
|
|
995
1078
|
_classPrivateFieldGet2(_template, this).configure(_classPrivateFieldGet2(_config, this));
|
|
996
1079
|
return _classPrivateFieldGet2(_config, this);
|
|
997
1080
|
}
|
|
1081
|
+
}, {
|
|
1082
|
+
key: "filePath",
|
|
1083
|
+
value: function filePath(name) {
|
|
1084
|
+
return ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1085
|
+
}
|
|
1086
|
+
}, {
|
|
1087
|
+
key: "require",
|
|
1088
|
+
value: function require(name) {
|
|
1089
|
+
var scope = this.context({});
|
|
1090
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(function () {
|
|
1091
|
+
return scope.getMacro();
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
998
1094
|
}, {
|
|
999
1095
|
key: "render",
|
|
1000
1096
|
value: function render(name, data) {
|
|
1001
|
-
var _this = this;
|
|
1002
|
-
var filepath = ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1003
1097
|
var scope = this.context(data);
|
|
1004
|
-
return _assertClassBrand(_EJS_brand, this, _output).call(this,
|
|
1098
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(this.outputContent(name, scope));
|
|
1099
|
+
}
|
|
1100
|
+
}, {
|
|
1101
|
+
key: "outputContent",
|
|
1102
|
+
value: function outputContent(name, scope) {
|
|
1103
|
+
var _this = this;
|
|
1104
|
+
return function (content) {
|
|
1005
1105
|
if (scope.getExtend()) {
|
|
1006
1106
|
scope.setExtend(false);
|
|
1007
|
-
|
|
1008
|
-
var _data = scope.clone();
|
|
1009
|
-
return _this.render(layout, _data);
|
|
1107
|
+
return _this.renderLayout(scope.getLayout(), scope, name);
|
|
1010
1108
|
}
|
|
1011
1109
|
return content;
|
|
1012
|
-
}
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1112
|
+
}, {
|
|
1113
|
+
key: "renderLayout",
|
|
1114
|
+
value: function renderLayout(name, data, parent) {
|
|
1115
|
+
var scope = this.context(data);
|
|
1116
|
+
if (parent) scope.setParentTemplate(parent);
|
|
1117
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, this.filePath(name), scope).then(this.outputContent(name, scope));
|
|
1013
1118
|
}
|
|
1014
1119
|
}, {
|
|
1015
1120
|
key: "helpers",
|
|
@@ -1036,15 +1141,6 @@
|
|
|
1036
1141
|
value: function create(options) {
|
|
1037
1142
|
return new this.constructor(options);
|
|
1038
1143
|
}
|
|
1039
|
-
}, {
|
|
1040
|
-
key: "require",
|
|
1041
|
-
value: function require(name) {
|
|
1042
|
-
var filepath = ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1043
|
-
var scope = this.context({});
|
|
1044
|
-
return _assertClassBrand(_EJS_brand, this, _output).call(this, filepath, scope).then(function () {
|
|
1045
|
-
return scope.getMacro();
|
|
1046
|
-
});
|
|
1047
|
-
}
|
|
1048
1144
|
}]);
|
|
1049
1145
|
}();
|
|
1050
1146
|
function _output(path, scope) {
|
package/dist/umd/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ejs={})}(this,(function(t){"use strict";function e(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}function n(t,e,n){return e=h(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,p()?Reflect.construct(e,n||[],h(t).constructor):e.apply(t,n))}function r(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,n){return t.get(e(t,n))}function u(t,e,n){r(t,e),e.set(t,n)}function c(t,n,r){return t.set(e(t,n),r),r}function s(t,e){r(t,e),e.add(t)}function a(t,e,n){return e&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,y(r.key),r)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function f(t,e,n){return(e=y(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&v(t,e)}function p(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(p=function(){return!!t})()}function v(t,e){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},v(t,e)}function y(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function g(t){var e="function"==typeof Map?new Map:void 0;return g=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(p())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var i=new(t.bind.apply(t,r));return n&&v(i,n.prototype),i}(t,arguments,h(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),v(n,t)},g(t)}var d=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},b=function(t){return Array.isArray(t)},w=function(t){return"function"==typeof t},m=function(t){return"string"==typeof t},k=function(t){return"boolean"==typeof t},E=function(t){return void 0===t},j="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),O={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},x={"&":"&","<":"<",">":">",'"':""","'":"'"},S=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},M=S(x),P=S(O),F=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(M,(function(t){return x[t]}))},T=function(t,e){var n=t;return null==n?"":!0===Boolean(e)?F(n):n},W=function(t,e){if(!1===function(t,e){return Boolean(t instanceof e)}(t,e))throw new TypeError("".concat(t," in not instance of ").concat(e))},B=function(t,e,n){for(var r=t,i=String(e).split("."),o=i.pop(),u=0;u<i.length;u++){var c=i[u];if(w(r.toJSON)&&(r=r.toJSON()),n&&!1===r.hasOwnProperty(c)){r={};break}r=r[c]=r[c]||{}}return w(r.toJSON)&&(r=r.toJSON()),[r,o]},R=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},A=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return n.filter((function(t){return t})).reduce((function(t,e){return Object.assign(t,e)}),t)},N=function(){},C=function(t,e){var n;for(n in t)L(t,n)&&e(t[n],n,t)},$=function(t,e){return function(t,e){var n=t instanceof Array,r=n?[]:{};return C(t,(function(t,i,o){var u=e(t,i,o);!1===E(u)&&(n?r.push(u):r[i]=u)})),r}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},L=function(t,e){return t&&t.hasOwnProperty(e)},U={export:"ejsPrecompiled",cache:!0,chokidar:null,path:"views",resolver:function(t,e){return Promise.resolve(["resolver is not defined",t,e].join(" "))},extension:"ejs",rmWhitespace:!0,withObject:!0,globalHelpers:[],vars:{SCOPE:"ejs",COMPONENT:"ui",ELEMENT:"el",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},_=function(t,e){A(t,{path:d(m,U.path,t.path,e.path),export:d(m,U.export,t.export,e.export),resolver:d(w,U.resolver,t.resolver,e.resolver),extension:d(m,U.extension,t.extension,e.extension),withObject:d(k,U.withObject,t.withObject,e.withObject),rmWhitespace:d(k,U.rmWhitespace,t.rmWhitespace,e.rmWhitespace),cache:d(k,U.cache,t.cache,e.cache),token:A({},U.token,t.token,e.token),vars:A({},U.vars,t.vars,e.vars),globalHelpers:d(b,U.globalHelpers,t.globalHelpers,e.globalHelpers)})},H="undefined"!=typeof globalThis?globalThis:window||self,q=new WeakMap,J=new WeakMap,D=function(){return a((function t(e){i(this,t),u(this,q,!0),u(this,J,{}),this.configure(e)}),[{key:"load",value:function(t){o(q,this)&&A(o(J,this),t||{})}},{key:"get",value:function(t){if(o(q,this))return o(J,this)[t]}},{key:"set",value:function(t,e){o(q,this)&&(o(J,this)[t]=e)}},{key:"exist",value:function(t){return L(o(J,this),t)}},{key:"clear",value:function(){c(J,this,{})}},{key:"remove",value:function(t){delete o(J,this)[t]}},{key:"resolve",value:function(t){return Promise.resolve(this.get(t))}},{key:"configure",value:function(t){c(q,this,t.cache),!1===j&&this.load(H[t.export])}}])}(),K=new WeakMap,V=new WeakMap,X=function(){return a((function t(e){i(this,t),u(this,K,{}),u(this,V,[{symbol:"-",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(t){return"')\n/**".concat(t,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(t){return"')\n".concat(t.trim(),"\n").concat(this.BUFFER,"('")}}]),this.configure(e)}),[{key:"configure",value:function(t){var e=this;o(K,this).withObject=t.withObject,o(K,this).rmWhitespace=t.rmWhitespace,o(K,this).token=t.token,o(K,this).vars=t.vars,o(K,this).globalHelpers=t.globalHelpers,o(K,this).matches=[],o(K,this).formats=[],o(K,this).slurp={match:"[s\t\n]*",start:[o(K,this).token.start,"_"],end:["_",o(K,this).token.end]},o(V,this).forEach((function(t){o(K,e).matches.push(o(K,e).token.start.concat(t.symbol).concat(o(K,e).token.regex).concat(o(K,e).token.end)),o(K,e).formats.push(t.format.bind(o(K,e).vars))})),o(K,this).regex=new RegExp(o(K,this).matches.join("|").concat("|$"),"g"),o(K,this).slurpStart=new RegExp([o(K,this).slurp.match,o(K,this).slurp.start.join("")].join(""),"gm"),o(K,this).slurpEnd=new RegExp([o(K,this).slurp.end.join(""),o(K,this).slurp.match].join(""),"gm")}},{key:"compile",value:function(t,e){var n=this,r=o(K,this).vars,i=r.SCOPE,u=r.SAFE,c=r.BUFFER,s=r.COMPONENT,a=r.ELEMENT,f=o(K,this).globalHelpers;o(K,this).rmWhitespace&&(t=String(t).replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=String(t).replace(o(K,this).slurpStart,o(K,this).token.start).replace(o(K,this).slurpEnd,o(K,this).token.end);var h,l,p,v="".concat(c,"('");h=o(K,this).regex,l=function(e,r,i){v+=(""+t.slice(r,i)).replace(P,(function(t){return"\\"+O[t]})),e.forEach((function(t,e){t&&(v+=o(K,n).formats[e](t))}))},p=0,t.replace(h,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return l(t,p,e),p=e+n.length,n})),v="try{".concat(v+="');","}catch(e){return ").concat(c,".error(e)}"),o(K,this).withObject&&(v="with(".concat(i,"){").concat(v,"}")),v="".concat(c,".start();").concat(v,"return ").concat(c,".end();"),v+="\n//# sourceURL=".concat(e);var y=null,g=[i,c,u,s,a].concat(f);try{(y=Function.apply(null,g.concat(v))).source="(function(".concat(g.join(","),"){\n").concat(v,"\n});")}catch(t){throw t.filename=e,t.source=v,t}return y}}])}(),Y=new WeakMap,z=new WeakMap,G=new WeakMap,I=new WeakMap,Q=new WeakSet,Z=function(){return a((function t(e,n,r){i(this,t),s(this,Q),u(this,Y,void 0),u(this,z,void 0),u(this,G,void 0),u(this,I,void 0),W(n,D),W(r,X),c(z,this,n),c(G,this,r),this.configure(e)}),[{key:"configure",value:function(t){c(Y,this,t.path),w(t.resolver)&&c(I,this,t.resolver)}},{key:"get",value:function(t){var n=this;return o(z,this).exist(t)?o(z,this).resolve(t):e(Q,this,tt).call(this,t).then((function(r){return e(Q,n,et).call(n,t,e(Q,n,nt).call(n,r,t))}))}}])}();function tt(t){return o(I,this).call(this,o(Y,this),t)}function et(t,e){return o(z,this).set(t,e),e}function nt(t,e){return w(t)?t:o(G,this).compile(t,e)}var rt=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],it=" ",ot='"',ut="/",ct="<",st=">",at=function(t,e,n){var r=[],i=-1===rt.indexOf(t),o=function(t,e){var n=[];return C(t,(function(t,r,i){var o=e(t,r,i);!1===E(o)&&n.push(o)})),n}(e,(function(t,e){if(null!=t)return[F(e),[ot,F(t),ot].join("")].join("=")})).join(it);return r.push([ct,t,it,o,st].join("")),n&&i&&r.push(n instanceof Array?n.join(""):n),i&&r.push([ct,ut,t,st].join("")),r.join("")},ft=function(t){function e(t){var r;return i(this,e),f(r=n(this,e),"code",0),r.message=t,r}return l(e,t),a(e,[{key:"getCode",value:function(){return this.code}},{key:"getMessage",value:function(){return this.message}},{key:"toString",value:function(){return this.getMessage()}}])}(g(Error)),ht=function(t){function e(){var t;i(this,e);for(var r=arguments.length,o=new Array(r),u=0;u<r;u++)o[u]=arguments[u];return f(t=n(this,e,[].concat(o)),"code",404),t}return l(e,t),a(e)}(ft),lt=function(t){function e(){var t;i(this,e);for(var r=arguments.length,o=new Array(r),u=0;u<r;u++)o[u]=arguments[u];return f(t=n(this,e,[].concat(o)),"code",500),t}return l(e,t),a(e)}(ft);function pt(t){return Promise.all(t||[]).then((function(t){return t.join("")})).catch((function(t){return t}))}function vt(){var t=[],e=[],n=function(t){e.push(t)};return n.start=function(){e=[]},n.backup=function(){t.push(e.concat()),e=[]},n.restore=function(){var n=e.concat();return e=t.pop(),pt(n)},n.error=function(t){return e=t,Promise.reject(new lt(e.message));var e},n.end=function(){return pt(e)},n}var yt=new WeakMap,gt=function(){return a((function t(e,n){i(this,t),u(this,yt,void 0),this.configure(e,n)}),[{key:"create",value:function(t){return new(o(yt,this))(t)}},{key:"configure",value:function(t,e){c(yt,this,function(t,e){var n,r=t.vars,i=r.BLOCKS,o=r.MACRO,u=r.EXTEND,c=r.LAYOUT,s=r.BUFFER,a=r.SAFE,h=r.SCOPE,l=r.COMPONENT,p=r.ELEMENT;function v(t){this[i]={},this[o]={},Object.assign(this,$(t,[h,s,a,l,p]))}return Object.assign(v.prototype,e),Object.defineProperties(v.prototype,(f(f(f(f(f(f(f(f(f(f(n={},s,{value:vt()}),i,{value:{},writable:!0}),o,{value:{},writable:!0}),c,{value:!1,writable:!0}),u,{value:!1,writable:!0}),"useSafeValue",{get:function(){return T}}),"useComponent",{get:function(){return w(this[l])?this[l].bind(this):function(){throw new Error("".concat(l," must be a function"))}}}),"useElement",{get:function(){return w(this[p])?this[p].bind(this):function(){throw new Error("".concat(p," must be a function"))}}}),"getMacro",{value:function(){return this[o]}}),"getBuffer",{value:function(){return this[s]}}),f(f(f(f(f(f(f(f(f(f(n,"getBlocks",{value:function(){return this[i]}}),"setExtend",{value:function(t){this[u]=t}}),"getExtend",{value:function(){return this[u]}}),"setLayout",{value:function(t){this[c]=t}}),"getLayout",{value:function(){return this[c]}}),"clone",{value:function(t){var e=[c,u,s];return!0===t&&e.push(i),$(this,e)}}),"extend",{value:function(t){this.setExtend(!0),this.setLayout(t)}}),"echo",{value:function(t){var e=this.getBuffer();[].slice.call(arguments).forEach(e)}}),"fn",{value:function(t){var e=this.getBuffer(),n=this;return function(){if(w(t))return e.backup(),e(t.apply(n,arguments)),e.restore()}}}),"macro",{value:function(t,e){var n=this.getMacro(),r=this.fn(e),i=this;n[t]=function(){return i.echo(r.apply(void 0,arguments))}}}),f(f(f(f(f(f(f(f(f(f(n,"call",{value:function(t){var e=this.getMacro()[t],n=[].slice.call(arguments,1);if(w(e))return e.apply(e,n)}}),"block",{value:function(t,e){var n=this,r=this.getBlocks();if(r[t]=r[t]||[],r[t].push(this.fn(e)),!this.getExtend()){var i=Object.assign([],r[t]),o=function(){return i.shift()},u=function(){var t=o();return t?function(){n.echo(t(u()))}:N};this.echo(o()(u()))}}}),"hasBlock",{value:function(t){return this.getBlocks().hasOwnProperty(t)}}),"include",{value:function(t,e,n){var r=!1===n?{}:this.clone(!0),i=A(r,e||{}),o=this.render(t,i);this.echo(o)}}),"use",{value:function(t,e){var n=this;this.echo(Promise.resolve(this.require(t)).then((function(t){var r=n.getMacro();C(t,(function(t,n){r[[e,n].join(".")]=t}))})))}}),"async",{value:function(t,e){this.echo(Promise.resolve(t).then(e))}}),"get",{value:function(t,e){var n=B(this,t,!0),r=n.shift(),i=n.pop();return L(r,i)?r[i]:e}}),"set",{value:function(t,e){var n=B(this,t,!1),r=n.shift(),i=n.pop();return this.getExtend()&&L(r,i)?r[i]:r[i]=e}}),"each",{value:function(t,e){m(t)&&(t=this.get(t,[])),C(t,e)},writable:!0}),"el",{value:function(t,e,n){n=w(n)?this.fn(n)():n,this.echo(Promise.resolve(n).then((function(n){return at(t,e,n)})))},writable:!0}),f(n,"ui",{value:function(t){},writable:!0}))),v}(t,e))}},{key:"helpers",value:function(t){A(o(yt,this).prototype,t||{})}}])}(),dt=new WeakMap,bt=new WeakMap,wt=new WeakMap,mt=new WeakMap,kt=new WeakMap,Et=new WeakMap,jt=new WeakSet,Ot=function(){return a((function t(e){i(this,t),s(this,jt),u(this,dt,{}),u(this,bt,{}),u(this,wt,void 0),u(this,mt,void 0),u(this,kt,void 0),u(this,Et,void 0),_(o(dt,this),e||{}),c(wt,this,new gt(o(dt,this),o(bt,this))),c(mt,this,new X(o(dt,this))),c(kt,this,new D(o(dt,this))),c(Et,this,new Z(o(dt,this),o(kt,this),o(mt,this))),function(t){(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).forEach((function(e){e in t&&(t[e]=t[e].bind(t))}))}(this,["configure","create","render","require","context","preload","compile","helpers"]),this.helpers({require:this.require,render:this.render})}),[{key:"configure",value:function(t){return _(o(dt,this),t||{}),o(wt,this).configure(o(dt,this),o(bt,this)),o(mt,this).configure(o(dt,this)),o(kt,this).configure(o(dt,this)),o(Et,this).configure(o(dt,this)),o(dt,this)}},{key:"render",value:function(t,n){var r=this,i=R(t,o(dt,this).extension),u=this.context(n);return e(jt,this,xt).call(this,i,u).then((function(t){if(u.getExtend()){u.setExtend(!1);var e=u.getLayout(),n=u.clone();return r.render(e,n)}return t}))}},{key:"helpers",value:function(t){o(wt,this).helpers(A(o(bt,this),t))}},{key:"context",value:function(t){return o(wt,this).create(t)}},{key:"compile",value:function(t,e){return o(mt,this).compile(t,e)}},{key:"preload",value:function(t){return o(kt,this).load(t||{})}},{key:"create",value:function(t){return new this.constructor(t)}},{key:"require",value:function(t){var n=R(t,o(dt,this).extension),r=this.context({});return e(jt,this,xt).call(this,n,r).then((function(){return r.getMacro()}))}}])}();function xt(t,e){var n=o(dt,this).globalHelpers,r=[e,e.getBuffer(),e.useSafeValue,e.useComponent,e.useElement].concat(n.filter((function(t){return w(e[t])})).map((function(t){return e[t].bind(e)})));return o(Et,this).get(t).then((function(t){return t.apply(e,r)}))}var St={};var Mt=new Ot({resolver:function(t,e){return new Promise((function(n,r){St.readFile(function(t,e){return(e=[t,e].join("/")).replace(/\/\//g,"/")}(t,e),(function(t,e){t?r(new ft(t)):n(e.toString())}))}))}}),Pt=Mt.render,Ft=Mt.context,Tt=Mt.compile,Wt=Mt.helpers,Bt=Mt.preload,Rt=Mt.configure,At=Mt.create,Nt=function(t,e){return function(n,r,i){w(r)&&(i=r,r={});var o=A({},(r=r||{}).settings),u=d(m,U.path,o.views),c=d(k,U.cache,o["view cache"]),s=A({},o["view options"]),a=St.relative(u,n);return s.path=u,s.cache=c,t(s),e(a,r).then((function(t){i(null,t)})).catch((function(t){i(t)}))}}(Rt,Pt);t.TemplateError=ft,t.TemplateNotFound=ht,t.TemplateSyntaxError=lt,t.__express=Nt,t.compile=Tt,t.configure=Rt,t.context=Ft,t.create=At,t.helpers=Wt,t.preload=Bt,t.render=Pt}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ejs={})}(this,(function(t){"use strict";function e(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}function n(t,e,n){return e=h(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,p()?Reflect.construct(e,n||[],h(t).constructor):e.apply(t,n))}function r(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,n){return t.get(e(t,n))}function u(t,e,n){r(t,e),e.set(t,n)}function c(t,n,r){return t.set(e(t,n),r),r}function a(t,e){r(t,e),e.add(t)}function s(t,e,n){return e&&function(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,y(r.key),r)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function f(t,e,n){return(e=y(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function h(t){return h=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},h(t)}function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&v(t,e)}function p(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(p=function(){return!!t})()}function v(t,e){return v=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},v(t,e)}function y(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function g(t){var e="function"==typeof Map?new Map:void 0;return g=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return function(t,e,n){if(p())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var i=new(t.bind.apply(t,r));return n&&v(i,n.prototype),i}(t,arguments,h(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),v(n,t)},g(t)}var d=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},b=function(t){return Array.isArray(t)},m=function(t){return"function"==typeof t},w=function(t){return"string"==typeof t},k=function(t){return"boolean"==typeof t},j=function(t){return void 0===t},E="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),O={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},x={"&":"&","<":"<",">":">",'"':""","'":"'"},P=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},S=P(x),M=P(O),T=function(){return(""+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")).replace(S,(function(t){return x[t]}))},F=function(t,e){var n=t;return null==n?"":!0===Boolean(e)?T(n):n},W=function(t,e){if(!1===function(t,e){return Boolean(t instanceof e)}(t,e))throw new TypeError("".concat(t," in not instance of ").concat(e))},B=function(t,e,n){for(var r=t,i=String(e).split("."),o=i.pop(),u=0;u<i.length;u++){var c=i[u];if(m(r.toJSON)&&(r=r.toJSON()),n&&!1===r.hasOwnProperty(c)){r={};break}r=r[c]=r[c]||{}}return m(r.toJSON)&&(r=r.toJSON()),[r,o]},R=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return n.filter((function(t){return t})).reduce((function(t,e){return Object.assign(t,e)}),t)},C=function(){},A=function(t,e){var n;for(n in t)L(t,n)&&e(t[n],n,t)},N=function(t,e){return function(t,e){var n=t instanceof Array,r=n?[]:{};return A(t,(function(t,i,o){var u=e(t,i,o);!1===j(u)&&(n?r.push(u):r[i]=u)})),r}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},L=function(t,e){return t&&t.hasOwnProperty(e)},$={export:"ejsPrecompiled",cache:!0,chokidar:null,path:"views",resolver:function(t,e){return Promise.resolve(["resolver is not defined",t,e].join(" "))},extension:"ejs",rmWhitespace:!0,withObject:!0,globalHelpers:[],vars:{SCOPE:"ejs",COMPONENT:"ui",ELEMENT:"el",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},U=function(t,e){R(t,{path:d(w,$.path,t.path,e.path),export:d(w,$.export,t.export,e.export),resolver:d(m,$.resolver,t.resolver,e.resolver),extension:d(w,$.extension,t.extension,e.extension),withObject:d(k,$.withObject,t.withObject,e.withObject),rmWhitespace:d(k,$.rmWhitespace,t.rmWhitespace,e.rmWhitespace),cache:d(k,$.cache,t.cache,e.cache),token:R({},$.token,t.token,e.token),vars:R({},$.vars,t.vars,e.vars),globalHelpers:d(b,$.globalHelpers,t.globalHelpers,e.globalHelpers)})},_="undefined"!=typeof globalThis?globalThis:window||self,H=new WeakMap,q=new WeakMap,J=function(){return s((function t(e){i(this,t),u(this,H,!0),u(this,q,{}),this.configure(e)}),[{key:"load",value:function(t){o(H,this)&&R(o(q,this),t||{})}},{key:"get",value:function(t){if(o(H,this))return o(q,this)[t]}},{key:"set",value:function(t,e){o(H,this)&&(o(q,this)[t]=e)}},{key:"exist",value:function(t){return L(o(q,this),t)}},{key:"clear",value:function(){c(q,this,{})}},{key:"remove",value:function(t){delete o(q,this)[t]}},{key:"resolve",value:function(t){return Promise.resolve(this.get(t))}},{key:"configure",value:function(t){c(H,this,t.cache),!1===E&&this.load(_[t.export])}}])}(),D=new WeakMap,K=new WeakMap,V=function(){return s((function t(e){i(this,t),u(this,D,{}),u(this,K,[{symbol:"-",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(t){return"')\n/**".concat(t,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(t){return"')\n".concat(t.trim(),"\n").concat(this.BUFFER,"('")}}]),this.configure(e)}),[{key:"configure",value:function(t){var e=this;o(D,this).withObject=t.withObject,o(D,this).rmWhitespace=t.rmWhitespace,o(D,this).token=t.token,o(D,this).vars=t.vars,o(D,this).globalHelpers=t.globalHelpers,o(D,this).matches=[],o(D,this).formats=[],o(D,this).slurp={match:"[s\t\n]*",start:[o(D,this).token.start,"_"],end:["_",o(D,this).token.end]},o(K,this).forEach((function(t){o(D,e).matches.push(o(D,e).token.start.concat(t.symbol).concat(o(D,e).token.regex).concat(o(D,e).token.end)),o(D,e).formats.push(t.format.bind(o(D,e).vars))})),o(D,this).regex=new RegExp(o(D,this).matches.join("|").concat("|$"),"g"),o(D,this).slurpStart=new RegExp([o(D,this).slurp.match,o(D,this).slurp.start.join("")].join(""),"gm"),o(D,this).slurpEnd=new RegExp([o(D,this).slurp.end.join(""),o(D,this).slurp.match].join(""),"gm")}},{key:"compile",value:function(t,e){var n=this,r=o(D,this).vars,i=r.SCOPE,u=r.SAFE,c=r.BUFFER,a=r.COMPONENT,s=r.ELEMENT,f=o(D,this).globalHelpers;o(D,this).rmWhitespace&&(t=String(t).replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=String(t).replace(o(D,this).slurpStart,o(D,this).token.start).replace(o(D,this).slurpEnd,o(D,this).token.end);var h,l,p,v="".concat(c,"('");h=o(D,this).regex,l=function(e,r,i){v+=(""+t.slice(r,i)).replace(M,(function(t){return"\\"+O[t]})),e.forEach((function(t,e){t&&(v+=o(D,n).formats[e](t))}))},p=0,t.replace(h,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return l(t,p,e),p=e+n.length,n})),v="try{".concat(v+="');","}catch(e){return ").concat(c,".error(e)}"),o(D,this).withObject&&(v="with(".concat(i,"){").concat(v,"}")),v="".concat(c,".start();").concat(v,"return ").concat(c,".end();"),v+="\n//# sourceURL=".concat(e);var y=null,g=[i,c,u,a,s].concat(f);try{(y=Function.apply(null,g.concat(v))).source="(function(".concat(g.join(","),"){\n").concat(v,"\n});")}catch(t){throw t.filename=e,t.source=v,t}return y}}])}(),X=new WeakMap,Y=new WeakMap,z=new WeakMap,G=new WeakMap,I=new WeakSet,Q=function(){return s((function t(e,n,r){i(this,t),a(this,I),u(this,X,void 0),u(this,Y,void 0),u(this,z,void 0),u(this,G,void 0),W(n,J),W(r,V),c(Y,this,n),c(z,this,r),this.configure(e)}),[{key:"configure",value:function(t){c(X,this,t.path),m(t.resolver)&&c(G,this,t.resolver)}},{key:"get",value:function(t){var n=this;return o(Y,this).exist(t)?o(Y,this).resolve(t):e(I,this,Z).call(this,t).then((function(r){return e(I,n,tt).call(n,t,e(I,n,et).call(n,r,t))}))}}])}();function Z(t){return o(G,this).call(this,o(X,this),t)}function tt(t,e){return o(Y,this).set(t,e),e}function et(t,e){return m(t)?t:o(z,this).compile(t,e)}var nt=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],rt=" ",it='"',ot="/",ut="<",ct=">",at=function(t,e,n){var r=[],i=-1===nt.indexOf(t),o=function(t,e){var n=[];return A(t,(function(t,r,i){var o=e(t,r,i);!1===j(o)&&n.push(o)})),n}(e,(function(t,e){if(null!=t)return[T(e),[it,T(t),it].join("")].join("=")})).join(rt);return r.push([ut,t,rt,o,ct].join("")),n&&i&&r.push(n instanceof Array?n.join(""):n),i&&r.push([ut,ot,t,ct].join("")),r.join("")},st=function(t){function e(t){var r;return i(this,e),f(r=n(this,e),"code",0),r.message=t,r}return l(e,t),s(e,[{key:"getCode",value:function(){return this.code}},{key:"getMessage",value:function(){return this.message}},{key:"toString",value:function(){return this.getMessage()}}])}(g(Error)),ft=function(t){function e(){var t;i(this,e);for(var r=arguments.length,o=new Array(r),u=0;u<r;u++)o[u]=arguments[u];return f(t=n(this,e,[].concat(o)),"code",404),t}return l(e,t),s(e)}(st),ht=function(t){function e(){var t;i(this,e);for(var r=arguments.length,o=new Array(r),u=0;u<r;u++)o[u]=arguments[u];return f(t=n(this,e,[].concat(o)),"code",500),t}return l(e,t),s(e)}(st);function lt(t){return Promise.all(t||[]).then((function(t){return t.join("")})).catch((function(t){return t}))}function pt(){var t=[],e=[],n=function(t){e.push(t)};return n.start=function(){e=[]},n.backup=function(){t.push(e.concat()),e=[]},n.restore=function(){var n=e.concat();return e=t.pop(),lt(n)},n.error=function(t){return e=t,Promise.reject(new ht(e.message));var e},n.end=function(){return lt(e)},n}var vt=Symbol("ContextScope.parentTemplate"),yt=new WeakMap,gt=function(){return s((function t(e,n){i(this,t),u(this,yt,void 0),this.configure(e,n)}),[{key:"create",value:function(t){return new(o(yt,this))(t)}},{key:"configure",value:function(t,e){c(yt,this,function(t,e){var n=t.vars,r=n.BLOCKS,i=n.MACRO,o=n.EXTEND,u=n.LAYOUT,c=n.BUFFER,a=n.SAFE,s=n.SCOPE,f=n.COMPONENT,h=n.ELEMENT;function l(t){this[vt]=null,this[r]={},this[i]={},Object.assign(this,N(t,[s,c,a,f,h]))}return Object.assign(l.prototype,e),Object.defineProperty(l.prototype,c,{value:pt()}),Object.defineProperty(l.prototype,r,{value:{},writable:!0}),Object.defineProperty(l.prototype,i,{value:{},writable:!0}),Object.defineProperty(l.prototype,u,{value:!1,writable:!0}),Object.defineProperty(l.prototype,o,{value:!1,writable:!0}),Object.defineProperty(l.prototype,vt,{value:null,writable:!0}),Object.defineProperties(l.prototype,{setParentTemplate:{value:function(t){return this[vt]=t,this}},getParentTemplate:{value:function(){return this[vt]}},useSafeValue:{get:function(){return F}},useComponent:{get:function(){return m(this[f])?this[f].bind(this):function(){throw new Error("".concat(f," must be a function"))}}},useElement:{get:function(){return m(this[h])?this[h].bind(this):function(){throw new Error("".concat(h," must be a function"))}}},getMacro:{value:function(){return this[i]}},getBuffer:{value:function(){return this[c]}},getBlocks:{value:function(){return this[r]}},setExtend:{value:function(t){return this[o]=t,this}},getExtend:{value:function(){return this[o]}},setLayout:{value:function(t){return this[u]=t,this}},getLayout:{value:function(){return this[u]}},clone:{value:function(t){var e=[u,o,c];return!0===t&&e.push(r),N(this,e)}},extend:{value:function(t){this.setExtend(!0),this.setLayout(t)}},echo:{value:function(t){var e=this.getBuffer();[].slice.call(arguments).forEach(e)}},fn:{value:function(t){var e=this.getBuffer(),n=this;return function(){if(m(t))return e.backup(),e(t.apply(n,arguments)),e.restore()}}},macro:{value:function(t,e){var n=this.getMacro(),r=this.fn(e),i=this;n[t]=function(){return i.echo(r.apply(void 0,arguments))}}},call:{value:function(t){var e=this.getMacro()[t],n=[].slice.call(arguments,1);if(m(e))return e.apply(e,n)}},block:{value:function(t,e){var n=this,r=this.getBlocks();if(r[t]=r[t]||[],r[t].push(this.fn(e)),!this.getExtend()){var i=Object.assign([],r[t]),o=function(){return i.shift()},u=function(){var t=o();return t?function(){n.echo(t(u()))}:C};this.echo(o()(u()))}}},hasBlock:{value:function(t){return this.getBlocks().hasOwnProperty(t)}},include:{value:function(t,e,n){var r=!1===n?{}:this.clone(!0),i=R(r,e||{}),o=this.render(t,i);this.echo(o)}},use:{value:function(t,e){var n=this;this.echo(Promise.resolve(this.require(t)).then((function(t){var r=n.getMacro();A(t,(function(t,n){r[[e,n].join(".")]=t}))})))}},async:{value:function(t,e){this.echo(Promise.resolve(t).then(e))}},get:{value:function(t,e){var n=B(this,t,!0),r=n.shift(),i=n.pop();return L(r,i)?r[i]:e}},set:{value:function(t,e){var n=B(this,t,!1),r=n.shift(),i=n.pop();return this.getParentTemplate()&&L(r,i)?r[i]:r[i]=e}},each:{value:function(t,e){w(t)&&(t=this.get(t,[])),A(t,e)},writable:!0},el:{value:function(t,e,n){n=m(n)?this.fn(n)():n,this.echo(Promise.resolve(n).then((function(n){return at(t,e,n)})))},writable:!0},ui:{value:function(t){},writable:!0}}),l}(t,e))}},{key:"helpers",value:function(t){R(o(yt,this).prototype,t||{})}}])}(),dt=new WeakMap,bt=new WeakMap,mt=new WeakMap,wt=new WeakMap,kt=new WeakMap,jt=new WeakMap,Et=new WeakSet,Ot=function(){return s((function t(e){i(this,t),a(this,Et),u(this,dt,{}),u(this,bt,{}),u(this,mt,void 0),u(this,wt,void 0),u(this,kt,void 0),u(this,jt,void 0),U(o(dt,this),e||{}),c(mt,this,new gt(o(dt,this),o(bt,this))),c(wt,this,new V(o(dt,this))),c(kt,this,new J(o(dt,this))),c(jt,this,new Q(o(dt,this),o(kt,this),o(wt,this))),function(t){(arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]).forEach((function(e){e in t&&(t[e]=t[e].bind(t))}))}(this,["configure","create","render","require","context","preload","compile","helpers"]),this.helpers({require:this.require,render:this.render})}),[{key:"configure",value:function(t){return U(o(dt,this),t||{}),o(mt,this).configure(o(dt,this),o(bt,this)),o(wt,this).configure(o(dt,this)),o(kt,this).configure(o(dt,this)),o(jt,this).configure(o(dt,this)),o(dt,this)}},{key:"filePath",value:function(t){return function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t}(t,o(dt,this).extension)}},{key:"require",value:function(t){var n=this.context({});return e(Et,this,xt).call(this,this.filePath(t),n).then((function(){return n.getMacro()}))}},{key:"render",value:function(t,n){var r=this.context(n);return e(Et,this,xt).call(this,this.filePath(t),r).then(this.outputContent(t,r))}},{key:"outputContent",value:function(t,e){var n=this;return function(r){return e.getExtend()?(e.setExtend(!1),n.renderLayout(e.getLayout(),e,t)):r}}},{key:"renderLayout",value:function(t,n,r){var i=this.context(n);return r&&i.setParentTemplate(r),e(Et,this,xt).call(this,this.filePath(t),i).then(this.outputContent(t,i))}},{key:"helpers",value:function(t){o(mt,this).helpers(R(o(bt,this),t))}},{key:"context",value:function(t){return o(mt,this).create(t)}},{key:"compile",value:function(t,e){return o(wt,this).compile(t,e)}},{key:"preload",value:function(t){return o(kt,this).load(t||{})}},{key:"create",value:function(t){return new this.constructor(t)}}])}();function xt(t,e){var n=o(dt,this).globalHelpers,r=[e,e.getBuffer(),e.useSafeValue,e.useComponent,e.useElement].concat(n.filter((function(t){return m(e[t])})).map((function(t){return e[t].bind(e)})));return o(jt,this).get(t).then((function(t){return t.apply(e,r)}))}var Pt={};var St=new Ot({resolver:function(t,e){return new Promise((function(n,r){Pt.readFile(function(t,e){return(e=[t,e].join("/")).replace(/\/\//g,"/")}(t,e),(function(t,e){t?r(new st(t)):n(e.toString())}))}))}}),Mt=St.render,Tt=St.context,Ft=St.compile,Wt=St.helpers,Bt=St.preload,Rt=St.configure,Ct=St.create,At=function(t,e){return function(n,r,i){m(r)&&(i=r,r={});var o=R({},(r=r||{}).settings),u=d(w,$.path,o.views),c=d(k,$.cache,o["view cache"]),a=R({},o["view options"]),s=Pt.relative(u,n);return a.path=u,a.cache=c,t(a),e(s,r).then((function(t){i(null,t)})).catch((function(t){i(t)}))}}(Rt,Mt);t.TemplateError=st,t.TemplateNotFound=ft,t.TemplateSyntaxError=ht,t.__express=At,t.compile=Ft,t.configure=Rt,t.context=Tt,t.create=Ct,t.helpers=Wt,t.preload=Bt,t.render=Mt}));
|