@kosatyi/ejs 0.0.110 → 0.0.111
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 +295 -200
- package/dist/cjs/bundler.js +9 -1
- package/dist/cjs/element.js +1 -1
- package/dist/cjs/index.js +361 -277
- package/dist/cjs/worker.js +302 -224
- package/dist/esm/browser.js +77 -62
- package/dist/esm/bundler.js +9 -1
- package/dist/esm/index.js +195 -191
- package/dist/esm/worker.js +81 -83
- package/dist/umd/browser.js +832 -737
- 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 +851 -767
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/worker.js +302 -224
- package/dist/umd/worker.min.js +1 -1
- package/package.json +4 -4
- package/types/context.d.ts +19 -4
- package/types/ejs.d.ts +1 -1
- package/types/error.d.ts +5 -2
- package/types/worker.d.ts +0 -6
- package/dist/kosatyi-ejs-0.0.109.tgz +0 -0
- package/dist/umd/browser.js.map +0 -7
- package/dist/umd/browser.min.js.map +0 -7
package/dist/umd/browser.js
CHANGED
|
@@ -1,813 +1,908 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ejsInstance = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return value.filter(name => {
|
|
52
|
-
const valid = jsVariableName.test(name);
|
|
53
|
-
if (valid === false) console.log(`ejsConfig.globals: expected '${name}' to be valid variable name --> skipped`);
|
|
54
|
-
return valid;
|
|
7
|
+
function _assertClassBrand(e, t, n) {
|
|
8
|
+
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
9
|
+
throw new TypeError("Private element is not present on this object");
|
|
10
|
+
}
|
|
11
|
+
function _checkPrivateRedeclaration(e, t) {
|
|
12
|
+
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
13
|
+
}
|
|
14
|
+
function _classPrivateFieldGet2(s, a) {
|
|
15
|
+
return s.get(_assertClassBrand(s, a));
|
|
16
|
+
}
|
|
17
|
+
function _classPrivateFieldInitSpec(e, t, a) {
|
|
18
|
+
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
19
|
+
}
|
|
20
|
+
function _classPrivateFieldSet2(s, a, r) {
|
|
21
|
+
return s.set(_assertClassBrand(s, a), r), r;
|
|
22
|
+
}
|
|
23
|
+
function _classPrivateMethodInitSpec(e, a) {
|
|
24
|
+
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
25
|
+
}
|
|
26
|
+
function _defineProperty(e, r, t) {
|
|
27
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
28
|
+
value: t,
|
|
29
|
+
enumerable: true,
|
|
30
|
+
configurable: true,
|
|
31
|
+
writable: true
|
|
32
|
+
}) : e[r] = t, e;
|
|
33
|
+
}
|
|
34
|
+
function ownKeys(e, r) {
|
|
35
|
+
var t = Object.keys(e);
|
|
36
|
+
if (Object.getOwnPropertySymbols) {
|
|
37
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
38
|
+
r && (o = o.filter(function (r) {
|
|
39
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
40
|
+
})), t.push.apply(t, o);
|
|
41
|
+
}
|
|
42
|
+
return t;
|
|
43
|
+
}
|
|
44
|
+
function _objectSpread2(e) {
|
|
45
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
46
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
47
|
+
r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
|
|
48
|
+
_defineProperty(e, r, t[r]);
|
|
49
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
50
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
55
51
|
});
|
|
56
|
-
}
|
|
52
|
+
}
|
|
53
|
+
return e;
|
|
54
|
+
}
|
|
55
|
+
function _toPrimitive(t, r) {
|
|
56
|
+
if ("object" != typeof t || !t) return t;
|
|
57
|
+
var e = t[Symbol.toPrimitive];
|
|
58
|
+
if (void 0 !== e) {
|
|
59
|
+
var i = e.call(t, r);
|
|
60
|
+
if ("object" != typeof i) return i;
|
|
61
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
62
|
+
}
|
|
63
|
+
return ("string" === r ? String : Number)(t);
|
|
64
|
+
}
|
|
65
|
+
function _toPropertyKey(t) {
|
|
66
|
+
var i = _toPrimitive(t, "string");
|
|
67
|
+
return "symbol" == typeof i ? i : i + "";
|
|
68
|
+
}
|
|
57
69
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
/**
|
|
71
|
+
* @type {EjsConfig}
|
|
72
|
+
*/
|
|
73
|
+
const ejsDefaults = {
|
|
74
|
+
precompiled: 'ejsPrecompiled',
|
|
75
|
+
cache: true,
|
|
76
|
+
path: 'views',
|
|
77
|
+
extension: 'ejs',
|
|
78
|
+
rmWhitespace: true,
|
|
79
|
+
strict: true,
|
|
80
|
+
resolver: (path, template) => {
|
|
81
|
+
return Promise.resolve(['resolver is not defined', path, template].join(' '));
|
|
82
|
+
},
|
|
83
|
+
globals: [],
|
|
84
|
+
vars: {
|
|
85
|
+
SCOPE: 'ejs',
|
|
86
|
+
COMPONENT: 'ui',
|
|
87
|
+
ELEMENT: 'el',
|
|
88
|
+
EXTEND: '$$e',
|
|
89
|
+
BUFFER: '$$a',
|
|
90
|
+
LAYOUT: '$$l',
|
|
91
|
+
BLOCKS: '$$b',
|
|
92
|
+
MACRO: '$$m',
|
|
93
|
+
SAFE: '$$v'
|
|
94
|
+
},
|
|
95
|
+
token: {
|
|
96
|
+
start: '<%',
|
|
97
|
+
end: '%>',
|
|
98
|
+
regex: '([\\s\\S]+?)'
|
|
99
|
+
}
|
|
100
|
+
};
|
|
72
101
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
"'"
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
102
|
+
const jsVariableName = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
|
|
103
|
+
const typeProp = function () {
|
|
104
|
+
const args = [].slice.call(arguments);
|
|
105
|
+
const callback = args.shift();
|
|
106
|
+
return args.filter(callback).pop();
|
|
107
|
+
};
|
|
108
|
+
const isArray = value => Array.isArray(value);
|
|
109
|
+
const isFunction = value => typeof value === 'function';
|
|
110
|
+
const isString = value => typeof value === 'string';
|
|
111
|
+
const isBoolean = value => typeof value === 'boolean';
|
|
112
|
+
const isArrayOfVariables = value => {
|
|
113
|
+
if (!isArray(value)) return false;
|
|
114
|
+
return value.filter(name => {
|
|
115
|
+
const valid = jsVariableName.test(name);
|
|
116
|
+
if (valid === false) console.log("ejsConfig.globals: expected '".concat(name, "' to be valid variable name --> skipped"));
|
|
117
|
+
return valid;
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const configSchema = (config, options) => {
|
|
122
|
+
return Object.assign(config, {
|
|
123
|
+
path: typeProp(isString, ejsDefaults.path, config.path, options.path),
|
|
124
|
+
precompiled: typeProp(isString, ejsDefaults.precompiled, config.export, options.export),
|
|
125
|
+
resolver: typeProp(isFunction, ejsDefaults.resolver, config.resolver, options.resolver),
|
|
126
|
+
extension: typeProp(isString, ejsDefaults.extension, config.extension, options.extension),
|
|
127
|
+
strict: typeProp(isBoolean, ejsDefaults.strict, config.strict, options.strict),
|
|
128
|
+
rmWhitespace: typeProp(isBoolean, ejsDefaults.rmWhitespace, config.rmWhitespace, options.rmWhitespace),
|
|
129
|
+
cache: typeProp(isBoolean, ejsDefaults.cache, config.cache, options.cache),
|
|
130
|
+
globals: typeProp(isArray, ejsDefaults.globals, config.globals, isArrayOfVariables(options.globals)),
|
|
131
|
+
token: Object.assign({}, ejsDefaults.token, config.token, options.token),
|
|
132
|
+
vars: Object.assign({}, ejsDefaults.vars, config.vars, options.vars)
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
const symbolEntities = {
|
|
137
|
+
"'": "'",
|
|
138
|
+
'\\': '\\',
|
|
139
|
+
'\r': 'r',
|
|
140
|
+
'\n': 'n',
|
|
141
|
+
'\t': 't',
|
|
142
|
+
'\u2028': 'u2028',
|
|
143
|
+
'\u2029': 'u2029'
|
|
144
|
+
};
|
|
145
|
+
const htmlEntities = {
|
|
146
|
+
'&': '&',
|
|
147
|
+
'<': '<',
|
|
148
|
+
'>': '>',
|
|
149
|
+
'"': '"',
|
|
150
|
+
"'": '''
|
|
151
|
+
};
|
|
152
|
+
const regexKeys = obj => new RegExp(['[', Object.keys(obj).join(''), ']'].join(''), 'g');
|
|
153
|
+
const htmlEntitiesMatch = regexKeys(htmlEntities);
|
|
154
|
+
const symbolEntitiesMatch = regexKeys(symbolEntities);
|
|
155
|
+
const entities = function () {
|
|
156
|
+
let string = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
157
|
+
return ('' + string).replace(htmlEntitiesMatch, match => htmlEntities[match]);
|
|
158
|
+
};
|
|
159
|
+
const symbols = string => {
|
|
160
|
+
return ('' + string).replace(symbolEntitiesMatch, match => '\\' + symbolEntities[match]);
|
|
161
|
+
};
|
|
162
|
+
const escapeValue = (value, escape) => {
|
|
163
|
+
const check = value;
|
|
164
|
+
return check == null ? '' : Boolean(escape) === true ? entities(check) : check;
|
|
165
|
+
};
|
|
166
|
+
const getPath = (context, name, strict) => {
|
|
167
|
+
let data = context;
|
|
168
|
+
let chunks = String(name).split('.');
|
|
169
|
+
let prop = chunks.pop();
|
|
170
|
+
for (let i = 0; i < chunks.length; i++) {
|
|
171
|
+
const part = chunks[i];
|
|
118
172
|
if (isFunction(data['toJSON'])) {
|
|
119
173
|
data = data.toJSON();
|
|
120
174
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
let prop;
|
|
125
|
-
for (prop in object) {
|
|
126
|
-
if (hasProp(object, prop)) {
|
|
127
|
-
callback(object[prop], prop, object);
|
|
128
|
-
}
|
|
175
|
+
if (strict && data.hasOwnProperty(part) === false) {
|
|
176
|
+
data = {};
|
|
177
|
+
break;
|
|
129
178
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
179
|
+
data = data[part] = data[part] || {};
|
|
180
|
+
}
|
|
181
|
+
if (isFunction(data['toJSON'])) {
|
|
182
|
+
data = data.toJSON();
|
|
183
|
+
}
|
|
184
|
+
return [data, prop];
|
|
185
|
+
};
|
|
186
|
+
const each = (object, callback) => {
|
|
187
|
+
let prop;
|
|
188
|
+
for (prop in object) {
|
|
189
|
+
if (hasProp(object, prop)) {
|
|
190
|
+
callback(object[prop], prop, object);
|
|
137
191
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
const omit = (object, list) => {
|
|
195
|
+
const result = _objectSpread2({}, object);
|
|
196
|
+
for (const key of list) {
|
|
197
|
+
delete result[key];
|
|
198
|
+
}
|
|
199
|
+
return result;
|
|
200
|
+
};
|
|
201
|
+
const hasProp = (object, prop) => {
|
|
202
|
+
return object && Object.hasOwn(object, prop);
|
|
203
|
+
};
|
|
204
|
+
const joinPath = (path, template) => {
|
|
205
|
+
template = [path, template].join('/');
|
|
206
|
+
template = template.replace(/\/\//g, '/');
|
|
207
|
+
return template;
|
|
208
|
+
};
|
|
209
|
+
const bindContext = function (object) {
|
|
210
|
+
let methods = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
211
|
+
for (let i = 0, len = methods.length; i < len; i++) {
|
|
212
|
+
const name = methods[i];
|
|
213
|
+
if (name in object) {
|
|
214
|
+
object[name] = object[name].bind(object);
|
|
155
215
|
}
|
|
156
|
-
}
|
|
216
|
+
}
|
|
217
|
+
};
|
|
157
218
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
219
|
+
class EjsError extends Error {
|
|
220
|
+
constructor(code, content) {
|
|
221
|
+
super(content);
|
|
222
|
+
this.code = code;
|
|
223
|
+
if (content instanceof Error) {
|
|
224
|
+
this.stack = content.stack;
|
|
225
|
+
this.message = content.message;
|
|
166
226
|
}
|
|
167
227
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
228
|
+
}
|
|
229
|
+
const error = (code, content) => {
|
|
230
|
+
throw new EjsError(code, content);
|
|
231
|
+
};
|
|
171
232
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const result = Promise.resolve(this.#resolver(this.#path, template, error));
|
|
194
|
-
this.#cache.set(template, result);
|
|
195
|
-
return result;
|
|
196
|
-
}
|
|
197
|
-
#compile(content, template) {
|
|
198
|
-
const cached = this.#cache.get(template);
|
|
199
|
-
if (typeof cached === 'function') return cached;
|
|
200
|
-
if (typeof content === 'string') {
|
|
201
|
-
content = this.#compiler.compile(content, template);
|
|
202
|
-
}
|
|
203
|
-
if (typeof content === 'function') {
|
|
204
|
-
this.#cache.set(template, content);
|
|
205
|
-
return content;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
get(template) {
|
|
209
|
-
return this.#resolve(template).then(content => {
|
|
210
|
-
return this.#compile(content, template);
|
|
211
|
-
});
|
|
233
|
+
var _path$1 = /*#__PURE__*/new WeakMap();
|
|
234
|
+
var _resolver = /*#__PURE__*/new WeakMap();
|
|
235
|
+
var _cache$2 = /*#__PURE__*/new WeakMap();
|
|
236
|
+
var _compiler$1 = /*#__PURE__*/new WeakMap();
|
|
237
|
+
var _EjsTemplate_brand = /*#__PURE__*/new WeakSet();
|
|
238
|
+
class EjsTemplate {
|
|
239
|
+
constructor(options, cache, compiler) {
|
|
240
|
+
_classPrivateMethodInitSpec(this, _EjsTemplate_brand);
|
|
241
|
+
_classPrivateFieldInitSpec(this, _path$1, void 0);
|
|
242
|
+
_classPrivateFieldInitSpec(this, _resolver, void 0);
|
|
243
|
+
_classPrivateFieldInitSpec(this, _cache$2, void 0);
|
|
244
|
+
_classPrivateFieldInitSpec(this, _compiler$1, void 0);
|
|
245
|
+
bindContext(this, this.constructor.exports);
|
|
246
|
+
_classPrivateFieldSet2(_cache$2, this, cache);
|
|
247
|
+
_classPrivateFieldSet2(_compiler$1, this, compiler);
|
|
248
|
+
this.configure(options !== null && options !== void 0 ? options : {});
|
|
249
|
+
}
|
|
250
|
+
configure(options) {
|
|
251
|
+
_classPrivateFieldSet2(_path$1, this, options.path);
|
|
252
|
+
if (isFunction(options.resolver)) {
|
|
253
|
+
_classPrivateFieldSet2(_resolver, this, options.resolver);
|
|
212
254
|
}
|
|
213
255
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
let index = 0;
|
|
218
|
-
content.replace(regex, function () {
|
|
219
|
-
const params = [].slice.call(arguments, 0, -1);
|
|
220
|
-
const offset = params.pop();
|
|
221
|
-
const match = params.shift();
|
|
222
|
-
callback(params, index, offset);
|
|
223
|
-
index = offset + match.length;
|
|
224
|
-
return match;
|
|
256
|
+
get(template) {
|
|
257
|
+
return _assertClassBrand(_EjsTemplate_brand, this, _resolve).call(this, template).then(content => {
|
|
258
|
+
return _assertClassBrand(_EjsTemplate_brand, this, _compile).call(this, content, template);
|
|
225
259
|
});
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function _resolve(template) {
|
|
263
|
+
const cached = _classPrivateFieldGet2(_cache$2, this).get(template);
|
|
264
|
+
if (cached instanceof Promise) return cached;
|
|
265
|
+
const result = Promise.resolve(_classPrivateFieldGet2(_resolver, this).call(this, _classPrivateFieldGet2(_path$1, this), template, error));
|
|
266
|
+
_classPrivateFieldGet2(_cache$2, this).set(template, result);
|
|
267
|
+
return result;
|
|
268
|
+
}
|
|
269
|
+
function _compile(content, template) {
|
|
270
|
+
const cached = _classPrivateFieldGet2(_cache$2, this).get(template);
|
|
271
|
+
if (typeof cached === 'function') return cached;
|
|
272
|
+
if (typeof content === 'string') {
|
|
273
|
+
content = _classPrivateFieldGet2(_compiler$1, this).compile(content, template);
|
|
274
|
+
}
|
|
275
|
+
if (typeof content === 'function') {
|
|
276
|
+
_classPrivateFieldGet2(_cache$2, this).set(template, content);
|
|
277
|
+
return content;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
_defineProperty(EjsTemplate, "exports", ['configure', 'get']);
|
|
281
|
+
|
|
282
|
+
const tokenList = [['-', (v, b, s) => "')\n".concat(b, "(").concat(s, "(").concat(v, ",1))\n").concat(b, "('")], ['=', (v, b, s) => "')\n".concat(b, "(").concat(s, "(").concat(v, "))\n").concat(b, "('")], ['#', (v, b) => "')\n/**".concat(v, "**/\n").concat(b, "('")], ['', (v, b) => "')\n".concat(v, "\n").concat(b, "('")]];
|
|
283
|
+
const tokensMatch = (regex, content, callback) => {
|
|
284
|
+
let index = 0;
|
|
285
|
+
content.replace(regex, function () {
|
|
286
|
+
const params = [].slice.call(arguments, 0, -1);
|
|
287
|
+
const offset = params.pop();
|
|
288
|
+
const match = params.shift();
|
|
289
|
+
callback(params, index, offset);
|
|
290
|
+
index = offset + match.length;
|
|
291
|
+
return match;
|
|
292
|
+
});
|
|
293
|
+
};
|
|
294
|
+
var _config$1 = /*#__PURE__*/new WeakMap();
|
|
295
|
+
class EjsCompiler {
|
|
296
|
+
constructor(options) {
|
|
297
|
+
_classPrivateFieldInitSpec(this, _config$1, {});
|
|
298
|
+
bindContext(this, this.constructor.exports);
|
|
299
|
+
this.configure(options);
|
|
300
|
+
}
|
|
301
|
+
configure(options) {
|
|
302
|
+
var _options$legacy;
|
|
303
|
+
_classPrivateFieldGet2(_config$1, this).strict = options.strict;
|
|
304
|
+
_classPrivateFieldGet2(_config$1, this).rmWhitespace = options.rmWhitespace;
|
|
305
|
+
_classPrivateFieldGet2(_config$1, this).token = options.token;
|
|
306
|
+
_classPrivateFieldGet2(_config$1, this).vars = options.vars;
|
|
307
|
+
_classPrivateFieldGet2(_config$1, this).globals = options.globals;
|
|
308
|
+
_classPrivateFieldGet2(_config$1, this).legacy = (_options$legacy = options.legacy) !== null && _options$legacy !== void 0 ? _options$legacy : true;
|
|
309
|
+
_classPrivateFieldGet2(_config$1, this).slurp = {
|
|
310
|
+
match: '[s\t\n]*',
|
|
311
|
+
start: [_classPrivateFieldGet2(_config$1, this).token.start, '_'],
|
|
312
|
+
end: ['_', _classPrivateFieldGet2(_config$1, this).token.end]
|
|
313
|
+
};
|
|
314
|
+
_classPrivateFieldGet2(_config$1, this).matches = [];
|
|
315
|
+
_classPrivateFieldGet2(_config$1, this).formats = [];
|
|
316
|
+
for (const [symbol, format] of tokenList) {
|
|
317
|
+
_classPrivateFieldGet2(_config$1, this).matches.push(_classPrivateFieldGet2(_config$1, this).token.start.concat(symbol).concat(_classPrivateFieldGet2(_config$1, this).token.regex).concat(_classPrivateFieldGet2(_config$1, this).token.end));
|
|
318
|
+
_classPrivateFieldGet2(_config$1, this).formats.push(format);
|
|
319
|
+
}
|
|
320
|
+
_classPrivateFieldGet2(_config$1, this).regex = new RegExp(_classPrivateFieldGet2(_config$1, this).matches.join('|').concat('|$'), 'g');
|
|
321
|
+
_classPrivateFieldGet2(_config$1, this).slurpStart = new RegExp([_classPrivateFieldGet2(_config$1, this).slurp.match, _classPrivateFieldGet2(_config$1, this).slurp.start.join('')].join(''), 'gm');
|
|
322
|
+
_classPrivateFieldGet2(_config$1, this).slurpEnd = new RegExp([_classPrivateFieldGet2(_config$1, this).slurp.end.join(''), _classPrivateFieldGet2(_config$1, this).slurp.match].join(''), 'gm');
|
|
323
|
+
if (_classPrivateFieldGet2(_config$1, this).globals.length) {
|
|
324
|
+
if (_classPrivateFieldGet2(_config$1, this).legacy) {
|
|
325
|
+
_classPrivateFieldGet2(_config$1, this).globalVariables = "const ".concat(_classPrivateFieldGet2(_config$1, this).globals.map(name => "".concat(name, "=").concat(_classPrivateFieldGet2(_config$1, this).vars.SCOPE, ".").concat(name)).join(','), ";");
|
|
326
|
+
} else {
|
|
327
|
+
_classPrivateFieldGet2(_config$1, this).globalVariables = "const {".concat(_classPrivateFieldGet2(_config$1, this).globals.join(','), "} = ").concat(_classPrivateFieldGet2(_config$1, this).vars.SCOPE, ";");
|
|
261
328
|
}
|
|
262
329
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
330
|
+
}
|
|
331
|
+
compile(content, path) {
|
|
332
|
+
const GLOBALS = _classPrivateFieldGet2(_config$1, this).globalVariables;
|
|
333
|
+
const {
|
|
334
|
+
SCOPE,
|
|
335
|
+
SAFE,
|
|
336
|
+
BUFFER,
|
|
337
|
+
COMPONENT,
|
|
338
|
+
ELEMENT
|
|
339
|
+
} = _classPrivateFieldGet2(_config$1, this).vars;
|
|
340
|
+
if (_classPrivateFieldGet2(_config$1, this).rmWhitespace) {
|
|
341
|
+
content = String(content).replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
|
|
342
|
+
}
|
|
343
|
+
content = String(content).replace(_classPrivateFieldGet2(_config$1, this).slurpStart, _classPrivateFieldGet2(_config$1, this).token.start).replace(_classPrivateFieldGet2(_config$1, this).slurpEnd, _classPrivateFieldGet2(_config$1, this).token.end);
|
|
344
|
+
let OUTPUT = "".concat(BUFFER, "('");
|
|
345
|
+
tokensMatch(_classPrivateFieldGet2(_config$1, this).regex, content, (params, index, offset) => {
|
|
346
|
+
OUTPUT += symbols(content.slice(index, offset));
|
|
347
|
+
params.forEach((value, index) => {
|
|
348
|
+
if (value) {
|
|
349
|
+
OUTPUT += _classPrivateFieldGet2(_config$1, this).formats[index](value.trim(), BUFFER, SAFE);
|
|
350
|
+
}
|
|
284
351
|
});
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
352
|
+
});
|
|
353
|
+
OUTPUT += "');";
|
|
354
|
+
OUTPUT = "try{".concat(OUTPUT, "}catch(e){return ").concat(BUFFER, ".error(e)}");
|
|
355
|
+
if (_classPrivateFieldGet2(_config$1, this).strict === false) {
|
|
356
|
+
OUTPUT = "with(".concat(SCOPE, "){").concat(OUTPUT, "}");
|
|
357
|
+
}
|
|
358
|
+
OUTPUT = "".concat(BUFFER, ".start();").concat(OUTPUT, "return ").concat(BUFFER, ".end();");
|
|
359
|
+
OUTPUT += "\n//# sourceURL=".concat(path);
|
|
360
|
+
if (GLOBALS) {
|
|
361
|
+
OUTPUT = "".concat(GLOBALS, "\n").concat(OUTPUT);
|
|
362
|
+
}
|
|
363
|
+
try {
|
|
364
|
+
const params = [SCOPE, COMPONENT, ELEMENT, BUFFER, SAFE];
|
|
365
|
+
const result = Function.apply(null, params.concat(OUTPUT));
|
|
366
|
+
result.source = "(function(".concat(params.join(','), "){\n").concat(OUTPUT, "\n});");
|
|
367
|
+
return result;
|
|
368
|
+
} catch (e) {
|
|
369
|
+
e.filename = path;
|
|
370
|
+
e.source = OUTPUT;
|
|
371
|
+
error(0, e);
|
|
305
372
|
}
|
|
306
373
|
}
|
|
374
|
+
}
|
|
375
|
+
_defineProperty(EjsCompiler, "exports", ['configure', 'compile']);
|
|
307
376
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
set(key, value) {
|
|
323
|
-
if (this.#cache) {
|
|
324
|
-
this.#list[key] = value;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
exist(key) {
|
|
328
|
-
if (this.#cache) {
|
|
329
|
-
return this.#list.hasOwnProperty(key);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
clear() {
|
|
333
|
-
Object.keys(this.#list).forEach(this.remove);
|
|
377
|
+
var _cache$1 = /*#__PURE__*/new WeakMap();
|
|
378
|
+
var _precompiled = /*#__PURE__*/new WeakMap();
|
|
379
|
+
var _list = /*#__PURE__*/new WeakMap();
|
|
380
|
+
class EjsCache {
|
|
381
|
+
constructor(options) {
|
|
382
|
+
_classPrivateFieldInitSpec(this, _cache$1, true);
|
|
383
|
+
_classPrivateFieldInitSpec(this, _precompiled, void 0);
|
|
384
|
+
_classPrivateFieldInitSpec(this, _list, {});
|
|
385
|
+
bindContext(this, this.constructor.exports);
|
|
386
|
+
this.configure(options);
|
|
387
|
+
}
|
|
388
|
+
get(key) {
|
|
389
|
+
if (_classPrivateFieldGet2(_cache$1, this)) {
|
|
390
|
+
return _classPrivateFieldGet2(_list, this)[key];
|
|
334
391
|
}
|
|
335
|
-
|
|
336
|
-
|
|
392
|
+
}
|
|
393
|
+
set(key, value) {
|
|
394
|
+
if (_classPrivateFieldGet2(_cache$1, this)) {
|
|
395
|
+
_classPrivateFieldGet2(_list, this)[key] = value;
|
|
337
396
|
}
|
|
338
|
-
|
|
339
|
-
|
|
397
|
+
}
|
|
398
|
+
exist(key) {
|
|
399
|
+
if (_classPrivateFieldGet2(_cache$1, this)) {
|
|
400
|
+
return _classPrivateFieldGet2(_list, this).hasOwnProperty(key);
|
|
340
401
|
}
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
402
|
+
}
|
|
403
|
+
clear() {
|
|
404
|
+
Object.keys(_classPrivateFieldGet2(_list, this)).forEach(this.remove);
|
|
405
|
+
}
|
|
406
|
+
remove(key) {
|
|
407
|
+
delete _classPrivateFieldGet2(_list, this)[key];
|
|
408
|
+
}
|
|
409
|
+
resolve(key) {
|
|
410
|
+
return Promise.resolve(this.get(key));
|
|
411
|
+
}
|
|
412
|
+
load(data) {
|
|
413
|
+
if (_classPrivateFieldGet2(_cache$1, this)) {
|
|
414
|
+
Object.assign(_classPrivateFieldGet2(_list, this), data || {});
|
|
345
415
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
416
|
+
}
|
|
417
|
+
configure(options) {
|
|
418
|
+
_classPrivateFieldSet2(_cache$1, this, options.cache);
|
|
419
|
+
_classPrivateFieldSet2(_precompiled, this, options.precompiled);
|
|
420
|
+
if (typeof window === 'object') {
|
|
421
|
+
this.load(window[_classPrivateFieldGet2(_precompiled, this)]);
|
|
352
422
|
}
|
|
353
423
|
}
|
|
424
|
+
}
|
|
425
|
+
_defineProperty(EjsCache, "exports", ['load', 'set', 'get', 'exist', 'clear', 'remove', 'resolve']);
|
|
354
426
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
427
|
+
const selfClosed = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
|
|
428
|
+
const space = ' ';
|
|
429
|
+
const quote = '"';
|
|
430
|
+
const equal = '=';
|
|
431
|
+
const slash = '/';
|
|
432
|
+
const lt = '<';
|
|
433
|
+
const gt = '>';
|
|
434
|
+
const eachAttribute = _ref => {
|
|
435
|
+
let [key, value] = _ref;
|
|
436
|
+
if (value !== null && value !== undefined) {
|
|
437
|
+
return [entities(key), [quote, entities(value), quote].join('')].join(equal);
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
const element = (tag, attrs, content) => {
|
|
441
|
+
const result = [];
|
|
442
|
+
const hasClosedTag = selfClosed.indexOf(tag) === -1;
|
|
443
|
+
const attributes = Object.entries(attrs !== null && attrs !== void 0 ? attrs : {}).map(eachAttribute).filter(e => e).join(space);
|
|
444
|
+
result.push([lt, tag, space, attributes, gt].join(''));
|
|
445
|
+
if (content && hasClosedTag) {
|
|
446
|
+
result.push(Array.isArray(content) ? content.join('') : content);
|
|
447
|
+
}
|
|
448
|
+
if (hasClosedTag) {
|
|
449
|
+
result.push([lt, slash, tag, gt].join(''));
|
|
450
|
+
}
|
|
451
|
+
return result.join('');
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
const resolve = list => {
|
|
455
|
+
return Promise.all(list || []).then(list => list.join('')).catch(e => error(0, e));
|
|
456
|
+
};
|
|
457
|
+
const reject = e => {
|
|
458
|
+
return Promise.reject(error(0, e));
|
|
459
|
+
};
|
|
460
|
+
const EjsBuffer = () => {
|
|
461
|
+
let store = [];
|
|
462
|
+
let array = [];
|
|
463
|
+
/**
|
|
464
|
+
*
|
|
465
|
+
* @param value
|
|
466
|
+
* @constructor
|
|
467
|
+
*/
|
|
468
|
+
const EjsBuffer = value => {
|
|
469
|
+
array.push(value);
|
|
367
470
|
};
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
const hasClosedTag = selfClosed.indexOf(tag) === -1;
|
|
371
|
-
const attributes = Object.entries(attrs ?? {}).map(eachAttribute).filter(e => e).join(space);
|
|
372
|
-
result.push([lt, tag, space, attributes, gt].join(''));
|
|
373
|
-
if (content && hasClosedTag) {
|
|
374
|
-
result.push(Array.isArray(content) ? content.join('') : content);
|
|
375
|
-
}
|
|
376
|
-
if (hasClosedTag) {
|
|
377
|
-
result.push([lt, slash, tag, gt].join(''));
|
|
378
|
-
}
|
|
379
|
-
return result.join('');
|
|
471
|
+
EjsBuffer.start = () => {
|
|
472
|
+
array = [];
|
|
380
473
|
};
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
return error(500, e);
|
|
385
|
-
});
|
|
474
|
+
EjsBuffer.backup = () => {
|
|
475
|
+
store.push(array.concat());
|
|
476
|
+
array = [];
|
|
386
477
|
};
|
|
387
|
-
|
|
388
|
-
|
|
478
|
+
EjsBuffer.restore = () => {
|
|
479
|
+
const result = array.concat();
|
|
480
|
+
array = store.pop();
|
|
481
|
+
return resolve(result);
|
|
389
482
|
};
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
* @param value
|
|
396
|
-
* @constructor
|
|
397
|
-
*/
|
|
398
|
-
const EjsBuffer = value => {
|
|
399
|
-
array.push(value);
|
|
400
|
-
};
|
|
401
|
-
EjsBuffer.start = () => {
|
|
402
|
-
array = [];
|
|
403
|
-
};
|
|
404
|
-
EjsBuffer.backup = () => {
|
|
405
|
-
store.push(array.concat());
|
|
406
|
-
array = [];
|
|
407
|
-
};
|
|
408
|
-
EjsBuffer.restore = () => {
|
|
409
|
-
const result = array.concat();
|
|
410
|
-
array = store.pop();
|
|
411
|
-
return resolve(result);
|
|
412
|
-
};
|
|
413
|
-
EjsBuffer.error = e => {
|
|
414
|
-
return reject(e);
|
|
415
|
-
};
|
|
416
|
-
EjsBuffer.end = () => {
|
|
417
|
-
return resolve(array);
|
|
418
|
-
};
|
|
419
|
-
return EjsBuffer;
|
|
483
|
+
EjsBuffer.error = e => {
|
|
484
|
+
return reject(e);
|
|
485
|
+
};
|
|
486
|
+
EjsBuffer.end = () => {
|
|
487
|
+
return resolve(array);
|
|
420
488
|
};
|
|
489
|
+
return EjsBuffer;
|
|
490
|
+
};
|
|
421
491
|
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
492
|
+
const PARENT = Symbol('EjsContext.parentTemplate');
|
|
493
|
+
const createContext$1 = (config, methods) => {
|
|
494
|
+
const globals = config.globals || [];
|
|
495
|
+
const {
|
|
496
|
+
BLOCKS,
|
|
497
|
+
MACRO,
|
|
498
|
+
EXTEND,
|
|
499
|
+
LAYOUT,
|
|
500
|
+
BUFFER,
|
|
501
|
+
SAFE,
|
|
502
|
+
SCOPE,
|
|
503
|
+
COMPONENT,
|
|
504
|
+
ELEMENT
|
|
505
|
+
} = config.vars;
|
|
506
|
+
class Context {
|
|
507
|
+
constructor(data) {
|
|
437
508
|
this[PARENT] = null;
|
|
438
509
|
this[BLOCKS] = {};
|
|
439
510
|
this[MACRO] = {};
|
|
440
511
|
Object.assign(this, omit(data, [SCOPE, BUFFER, SAFE, COMPONENT, ELEMENT]));
|
|
441
512
|
}
|
|
442
|
-
|
|
513
|
+
}
|
|
514
|
+
Object.defineProperties(Context.prototype, {
|
|
515
|
+
[BUFFER]: {
|
|
443
516
|
value: EjsBuffer()
|
|
444
|
-
}
|
|
445
|
-
|
|
517
|
+
},
|
|
518
|
+
[BLOCKS]: {
|
|
446
519
|
value: {},
|
|
447
520
|
writable: true
|
|
448
|
-
}
|
|
449
|
-
|
|
521
|
+
},
|
|
522
|
+
[MACRO]: {
|
|
450
523
|
value: {},
|
|
451
524
|
writable: true
|
|
452
|
-
}
|
|
453
|
-
|
|
525
|
+
},
|
|
526
|
+
[LAYOUT]: {
|
|
454
527
|
value: false,
|
|
455
528
|
writable: true
|
|
456
|
-
}
|
|
457
|
-
|
|
529
|
+
},
|
|
530
|
+
[EXTEND]: {
|
|
458
531
|
value: false,
|
|
459
532
|
writable: true
|
|
460
|
-
}
|
|
461
|
-
|
|
533
|
+
},
|
|
534
|
+
[PARENT]: {
|
|
462
535
|
value: null,
|
|
463
536
|
writable: true
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
value
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
throw new Error(`${COMPONENT} must be a function`);
|
|
487
|
-
};
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
},
|
|
491
|
-
useElement: {
|
|
492
|
-
get() {
|
|
493
|
-
if (isFunction(this[ELEMENT])) {
|
|
494
|
-
return this[ELEMENT].bind(this);
|
|
495
|
-
} else {
|
|
496
|
-
return () => {
|
|
497
|
-
throw new Error(`${ELEMENT} must be a function`);
|
|
498
|
-
};
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
},
|
|
502
|
-
useBuffer: {
|
|
503
|
-
get() {
|
|
504
|
-
return this[BUFFER];
|
|
505
|
-
}
|
|
506
|
-
},
|
|
507
|
-
getMacro: {
|
|
508
|
-
value() {
|
|
509
|
-
return this[MACRO];
|
|
510
|
-
}
|
|
511
|
-
},
|
|
512
|
-
getBlocks: {
|
|
513
|
-
value() {
|
|
514
|
-
return this[BLOCKS];
|
|
515
|
-
}
|
|
516
|
-
},
|
|
517
|
-
setExtend: {
|
|
518
|
-
value(value) {
|
|
519
|
-
this[EXTEND] = value;
|
|
520
|
-
return this;
|
|
521
|
-
}
|
|
522
|
-
},
|
|
523
|
-
getExtend: {
|
|
524
|
-
value() {
|
|
525
|
-
return this[EXTEND];
|
|
526
|
-
}
|
|
527
|
-
},
|
|
528
|
-
setLayout: {
|
|
529
|
-
value(layout) {
|
|
530
|
-
this[LAYOUT] = layout;
|
|
531
|
-
return this;
|
|
532
|
-
}
|
|
533
|
-
},
|
|
534
|
-
getLayout: {
|
|
535
|
-
value() {
|
|
536
|
-
return this[LAYOUT];
|
|
537
|
-
}
|
|
538
|
-
},
|
|
539
|
-
clone: {
|
|
540
|
-
value(exclude_blocks) {
|
|
541
|
-
const filter = [LAYOUT, EXTEND, BUFFER];
|
|
542
|
-
if (exclude_blocks === true) {
|
|
543
|
-
filter.push(BLOCKS);
|
|
544
|
-
}
|
|
545
|
-
return omit(this, filter);
|
|
546
|
-
}
|
|
547
|
-
},
|
|
548
|
-
extend: {
|
|
549
|
-
value(layout) {
|
|
550
|
-
this.setExtend(true);
|
|
551
|
-
this.setLayout(layout);
|
|
552
|
-
}
|
|
553
|
-
},
|
|
554
|
-
echo: {
|
|
555
|
-
value() {
|
|
556
|
-
return [].slice.call(arguments).forEach(this.useBuffer);
|
|
557
|
-
}
|
|
558
|
-
},
|
|
559
|
-
fn: {
|
|
560
|
-
value(callback) {
|
|
561
|
-
const context = this;
|
|
537
|
+
},
|
|
538
|
+
setParentTemplate: {
|
|
539
|
+
value(value) {
|
|
540
|
+
this[PARENT] = value;
|
|
541
|
+
return this;
|
|
542
|
+
}
|
|
543
|
+
},
|
|
544
|
+
getParentTemplate: {
|
|
545
|
+
value() {
|
|
546
|
+
return this[PARENT];
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
useEscapeValue: {
|
|
550
|
+
value() {
|
|
551
|
+
return escapeValue;
|
|
552
|
+
}
|
|
553
|
+
},
|
|
554
|
+
useComponent: {
|
|
555
|
+
value() {
|
|
556
|
+
if (isFunction(this[COMPONENT])) {
|
|
557
|
+
return this[COMPONENT].bind(this);
|
|
558
|
+
} else {
|
|
562
559
|
return function () {
|
|
563
|
-
|
|
564
|
-
context.useBuffer.backup();
|
|
565
|
-
context.useBuffer(callback.apply(context, arguments));
|
|
566
|
-
return context.useBuffer.restore();
|
|
567
|
-
}
|
|
568
|
-
};
|
|
569
|
-
}
|
|
570
|
-
},
|
|
571
|
-
macro: {
|
|
572
|
-
value(name, callback) {
|
|
573
|
-
const list = this.getMacro();
|
|
574
|
-
const macro = this.fn(callback);
|
|
575
|
-
const context = this;
|
|
576
|
-
list[name] = function () {
|
|
577
|
-
return context.echo(macro.apply(undefined, arguments));
|
|
560
|
+
error(2, "".concat(COMPONENT, " must be a function"));
|
|
578
561
|
};
|
|
579
562
|
}
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
}
|
|
590
|
-
},
|
|
591
|
-
block: {
|
|
592
|
-
value(name, callback) {
|
|
593
|
-
const blocks = this.getBlocks();
|
|
594
|
-
blocks[name] = blocks[name] || [];
|
|
595
|
-
blocks[name].push(this.fn(callback));
|
|
596
|
-
if (this.getExtend()) return;
|
|
597
|
-
const context = this;
|
|
598
|
-
const list = Object.assign([], blocks[name]);
|
|
599
|
-
const shift = function () {
|
|
600
|
-
return list.shift();
|
|
601
|
-
};
|
|
602
|
-
const next = function () {
|
|
603
|
-
const parent = shift();
|
|
604
|
-
if (parent) {
|
|
605
|
-
return function () {
|
|
606
|
-
context.echo(parent(next()));
|
|
607
|
-
};
|
|
608
|
-
} else {
|
|
609
|
-
return function () {};
|
|
610
|
-
}
|
|
563
|
+
}
|
|
564
|
+
},
|
|
565
|
+
useElement: {
|
|
566
|
+
value() {
|
|
567
|
+
if (isFunction(this[ELEMENT])) {
|
|
568
|
+
return this[ELEMENT].bind(this);
|
|
569
|
+
} else {
|
|
570
|
+
return () => {
|
|
571
|
+
error(2, "".concat(ELEMENT, " must be a function"));
|
|
611
572
|
};
|
|
612
|
-
this.echo(shift()(next()));
|
|
613
573
|
}
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
574
|
+
}
|
|
575
|
+
},
|
|
576
|
+
useBuffer: {
|
|
577
|
+
value() {
|
|
578
|
+
return this[BUFFER];
|
|
579
|
+
}
|
|
580
|
+
},
|
|
581
|
+
getMacro: {
|
|
582
|
+
value() {
|
|
583
|
+
return this[MACRO];
|
|
584
|
+
}
|
|
585
|
+
},
|
|
586
|
+
getBlocks: {
|
|
587
|
+
value() {
|
|
588
|
+
return this[BLOCKS];
|
|
589
|
+
}
|
|
590
|
+
},
|
|
591
|
+
setExtend: {
|
|
592
|
+
value(value) {
|
|
593
|
+
this[EXTEND] = value;
|
|
594
|
+
return this;
|
|
595
|
+
}
|
|
596
|
+
},
|
|
597
|
+
getExtend: {
|
|
598
|
+
value() {
|
|
599
|
+
return this[EXTEND];
|
|
600
|
+
}
|
|
601
|
+
},
|
|
602
|
+
setLayout: {
|
|
603
|
+
value(layout) {
|
|
604
|
+
this[LAYOUT] = layout;
|
|
605
|
+
return this;
|
|
606
|
+
}
|
|
607
|
+
},
|
|
608
|
+
getLayout: {
|
|
609
|
+
value() {
|
|
610
|
+
return this[LAYOUT];
|
|
611
|
+
}
|
|
612
|
+
},
|
|
613
|
+
clone: {
|
|
614
|
+
value(exclude_blocks) {
|
|
615
|
+
const filter = [LAYOUT, EXTEND, BUFFER];
|
|
616
|
+
if (exclude_blocks === true) {
|
|
617
|
+
filter.push(BLOCKS);
|
|
644
618
|
}
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
619
|
+
return omit(this, filter);
|
|
620
|
+
}
|
|
621
|
+
},
|
|
622
|
+
extend: {
|
|
623
|
+
value(layout) {
|
|
624
|
+
this.setExtend(true);
|
|
625
|
+
this.setLayout(layout);
|
|
626
|
+
}
|
|
627
|
+
},
|
|
628
|
+
echo: {
|
|
629
|
+
value() {
|
|
630
|
+
return [].slice.call(arguments).forEach(this.useBuffer());
|
|
631
|
+
}
|
|
632
|
+
},
|
|
633
|
+
fn: {
|
|
634
|
+
value(callback) {
|
|
635
|
+
const buffer = this.useBuffer();
|
|
636
|
+
const context = this;
|
|
637
|
+
return function () {
|
|
638
|
+
if (isFunction(callback)) {
|
|
639
|
+
buffer.backup();
|
|
640
|
+
buffer(callback.apply(context, arguments));
|
|
641
|
+
return buffer.restore();
|
|
653
642
|
}
|
|
654
|
-
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
},
|
|
646
|
+
macro: {
|
|
647
|
+
value(name, callback) {
|
|
648
|
+
const list = this.getMacro();
|
|
649
|
+
const macro = this.fn(callback);
|
|
650
|
+
const context = this;
|
|
651
|
+
list[name] = function () {
|
|
652
|
+
return context.echo(macro.apply(undefined, arguments));
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
},
|
|
656
|
+
call: {
|
|
657
|
+
value(name) {
|
|
658
|
+
const list = this.getMacro();
|
|
659
|
+
const macro = list[name];
|
|
660
|
+
const params = [].slice.call(arguments, 1);
|
|
661
|
+
if (isFunction(macro)) {
|
|
662
|
+
return macro.apply(macro, params);
|
|
655
663
|
}
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
664
|
+
}
|
|
665
|
+
},
|
|
666
|
+
block: {
|
|
667
|
+
value(name, callback) {
|
|
668
|
+
const blocks = this.getBlocks();
|
|
669
|
+
blocks[name] = blocks[name] || [];
|
|
670
|
+
blocks[name].push(this.fn(callback));
|
|
671
|
+
if (this.getExtend()) return;
|
|
672
|
+
const context = this;
|
|
673
|
+
const list = Object.assign([], blocks[name]);
|
|
674
|
+
const shift = function () {
|
|
675
|
+
return list.shift();
|
|
676
|
+
};
|
|
677
|
+
const next = function () {
|
|
678
|
+
const parent = shift();
|
|
679
|
+
if (parent) {
|
|
680
|
+
return function () {
|
|
681
|
+
context.echo(parent(next()));
|
|
682
|
+
};
|
|
683
|
+
} else {
|
|
684
|
+
return function () {};
|
|
661
685
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
writable: true
|
|
665
|
-
},
|
|
666
|
-
el: {
|
|
667
|
-
value(tag, attr, content) {
|
|
668
|
-
content = isFunction(content) ? this.fn(content)() : content;
|
|
669
|
-
this.echo(Promise.resolve(content).then(content => element(tag, attr, content)));
|
|
670
|
-
},
|
|
671
|
-
writable: true
|
|
672
|
-
},
|
|
673
|
-
ui: {
|
|
674
|
-
value() {},
|
|
675
|
-
writable: true
|
|
686
|
+
};
|
|
687
|
+
this.echo(shift()(next()));
|
|
676
688
|
}
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
value = value.bind(EjsContext.prototype);
|
|
689
|
+
},
|
|
690
|
+
hasBlock: {
|
|
691
|
+
value(name) {
|
|
692
|
+
return this.getBlocks().hasOwnProperty(name);
|
|
682
693
|
}
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
constructor(options, methods) {
|
|
691
|
-
bindContext(this, this.constructor.exports);
|
|
692
|
-
this.configure(options, methods);
|
|
693
|
-
}
|
|
694
|
-
create(data) {
|
|
695
|
-
return new this.#context(data);
|
|
696
|
-
}
|
|
697
|
-
helpers(methods) {
|
|
698
|
-
Object.assign(this.#context.prototype, methods);
|
|
699
|
-
}
|
|
700
|
-
configure(options, methods) {
|
|
701
|
-
this.#context = createContext$1(options, methods);
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
class EjsInstance {
|
|
706
|
-
#cache;
|
|
707
|
-
#context;
|
|
708
|
-
#compiler;
|
|
709
|
-
#template;
|
|
710
|
-
#config = {};
|
|
711
|
-
#methods = {};
|
|
712
|
-
static exports = ['configure', 'create', 'createContext', 'render', 'require', 'preload', 'compile', 'helpers'];
|
|
713
|
-
constructor() {
|
|
714
|
-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
715
|
-
bindContext(this, this.constructor.exports);
|
|
716
|
-
this.#methods = {};
|
|
717
|
-
this.#config = configSchema({}, options);
|
|
718
|
-
this.#context = new EjsContext(this.#config, this.#methods);
|
|
719
|
-
this.#compiler = new EjsCompiler(this.#config);
|
|
720
|
-
this.#cache = new EjsCache(this.#config);
|
|
721
|
-
this.#template = new EjsTemplate(this.#config, this.#cache, this.#compiler);
|
|
722
|
-
this.helpers({
|
|
723
|
-
render: this.render,
|
|
724
|
-
require: this.require
|
|
725
|
-
});
|
|
726
|
-
}
|
|
727
|
-
create(options) {
|
|
728
|
-
return new this.constructor(options);
|
|
729
|
-
}
|
|
730
|
-
configure(options) {
|
|
731
|
-
if (options) {
|
|
732
|
-
configSchema(this.#config, options);
|
|
733
|
-
this.#context.configure(this.#config, this.#methods);
|
|
734
|
-
this.#compiler.configure(this.#config);
|
|
735
|
-
this.#cache.configure(this.#config);
|
|
736
|
-
this.#template.configure(this.#config);
|
|
694
|
+
},
|
|
695
|
+
include: {
|
|
696
|
+
value(path, data, cx) {
|
|
697
|
+
const context = cx === false ? {} : this.clone(true);
|
|
698
|
+
const params = Object.assign(context, data || {});
|
|
699
|
+
const promise = this.render(path, params);
|
|
700
|
+
this.echo(promise);
|
|
737
701
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
return this.#compiler.compile(content, path);
|
|
748
|
-
}
|
|
749
|
-
helpers(methods) {
|
|
750
|
-
this.#context.helpers(Object.assign(this.#methods, methods));
|
|
751
|
-
}
|
|
752
|
-
async render(name, params) {
|
|
753
|
-
const data = this.createContext(params);
|
|
754
|
-
return this.#output(this.#path(name), data).then(this.#outputContent(name, data));
|
|
755
|
-
}
|
|
756
|
-
async require(name) {
|
|
757
|
-
const data = this.createContext({});
|
|
758
|
-
return this.#output(this.#path(name), data).then(() => data.getMacro());
|
|
759
|
-
}
|
|
760
|
-
#path(name) {
|
|
761
|
-
const ext = name.split('.').pop();
|
|
762
|
-
if (ext !== this.#config.extension) {
|
|
763
|
-
name = [name, this.#config.extension].join('.');
|
|
702
|
+
},
|
|
703
|
+
use: {
|
|
704
|
+
value(path, namespace) {
|
|
705
|
+
this.echo(Promise.resolve(this.require(path)).then(exports$1 => {
|
|
706
|
+
const list = this.getMacro();
|
|
707
|
+
each(exports$1, (macro, name) => {
|
|
708
|
+
list[[namespace, name].join('.')] = macro;
|
|
709
|
+
});
|
|
710
|
+
}));
|
|
764
711
|
}
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
712
|
+
},
|
|
713
|
+
get: {
|
|
714
|
+
value(name, defaults) {
|
|
715
|
+
const path = getPath(this, name, true);
|
|
716
|
+
const result = path.shift();
|
|
717
|
+
const prop = path.pop();
|
|
718
|
+
return hasProp(result, prop) ? result[prop] : defaults;
|
|
719
|
+
}
|
|
720
|
+
},
|
|
721
|
+
set: {
|
|
722
|
+
value(name, value) {
|
|
723
|
+
const path = getPath(this, name, false);
|
|
724
|
+
const result = path.shift();
|
|
725
|
+
const prop = path.pop();
|
|
726
|
+
if (this.getParentTemplate() && hasProp(result, prop)) {
|
|
727
|
+
return result[prop];
|
|
728
|
+
}
|
|
729
|
+
return result[prop] = value;
|
|
730
|
+
}
|
|
731
|
+
},
|
|
732
|
+
each: {
|
|
733
|
+
value(object, callback) {
|
|
734
|
+
if (isString(object)) {
|
|
735
|
+
object = this.get(object, []);
|
|
780
736
|
}
|
|
781
|
-
|
|
782
|
-
}
|
|
737
|
+
each(object, callback);
|
|
738
|
+
},
|
|
739
|
+
writable: true
|
|
740
|
+
},
|
|
741
|
+
el: {
|
|
742
|
+
value(tag, attr, content) {
|
|
743
|
+
content = isFunction(content) ? this.fn(content)() : content;
|
|
744
|
+
this.echo(Promise.resolve(content).then(content => element(tag, attr, content)));
|
|
745
|
+
},
|
|
746
|
+
writable: true
|
|
747
|
+
},
|
|
748
|
+
ui: {
|
|
749
|
+
value() {},
|
|
750
|
+
writable: true
|
|
751
|
+
},
|
|
752
|
+
require: {
|
|
753
|
+
value() {},
|
|
754
|
+
writable: true
|
|
755
|
+
},
|
|
756
|
+
render: {
|
|
757
|
+
value() {},
|
|
758
|
+
writable: true
|
|
759
|
+
}
|
|
760
|
+
});
|
|
761
|
+
Object.entries(methods).forEach(_ref => {
|
|
762
|
+
let [name, value] = _ref;
|
|
763
|
+
if (isFunction(value) && globals.includes(name)) {
|
|
764
|
+
value = value.bind(Context.prototype);
|
|
783
765
|
}
|
|
766
|
+
Context.prototype[name] = value;
|
|
767
|
+
});
|
|
768
|
+
return Context;
|
|
769
|
+
};
|
|
770
|
+
var _context$1 = /*#__PURE__*/new WeakMap();
|
|
771
|
+
class EjsContext {
|
|
772
|
+
constructor(options, methods) {
|
|
773
|
+
_classPrivateFieldInitSpec(this, _context$1, void 0);
|
|
774
|
+
bindContext(this, this.constructor.exports);
|
|
775
|
+
this.configure(options, methods);
|
|
784
776
|
}
|
|
777
|
+
create(data) {
|
|
778
|
+
return new (_classPrivateFieldGet2(_context$1, this))(data);
|
|
779
|
+
}
|
|
780
|
+
helpers(methods) {
|
|
781
|
+
Object.assign(_classPrivateFieldGet2(_context$1, this).prototype, methods);
|
|
782
|
+
}
|
|
783
|
+
configure(options, methods) {
|
|
784
|
+
_classPrivateFieldSet2(_context$1, this, createContext$1(options, methods));
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
_defineProperty(EjsContext, "exports", ['create', 'globals', 'helpers']);
|
|
785
788
|
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
789
|
+
var _cache = /*#__PURE__*/new WeakMap();
|
|
790
|
+
var _context = /*#__PURE__*/new WeakMap();
|
|
791
|
+
var _compiler = /*#__PURE__*/new WeakMap();
|
|
792
|
+
var _template = /*#__PURE__*/new WeakMap();
|
|
793
|
+
var _config = /*#__PURE__*/new WeakMap();
|
|
794
|
+
var _methods = /*#__PURE__*/new WeakMap();
|
|
795
|
+
var _EjsInstance_brand = /*#__PURE__*/new WeakSet();
|
|
796
|
+
class EjsInstance {
|
|
797
|
+
/**
|
|
798
|
+
*
|
|
799
|
+
* @param {EjsConfig} options
|
|
800
|
+
*/
|
|
801
|
+
constructor() {
|
|
802
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
803
|
+
_classPrivateMethodInitSpec(this, _EjsInstance_brand);
|
|
804
|
+
_classPrivateFieldInitSpec(this, _cache, void 0);
|
|
805
|
+
_classPrivateFieldInitSpec(this, _context, void 0);
|
|
806
|
+
_classPrivateFieldInitSpec(this, _compiler, void 0);
|
|
807
|
+
_classPrivateFieldInitSpec(this, _template, void 0);
|
|
808
|
+
_classPrivateFieldInitSpec(this, _config, {});
|
|
809
|
+
_classPrivateFieldInitSpec(this, _methods, {});
|
|
810
|
+
bindContext(this, this.constructor.exports);
|
|
811
|
+
_classPrivateFieldSet2(_methods, this, {});
|
|
812
|
+
_classPrivateFieldSet2(_config, this, configSchema({}, options));
|
|
813
|
+
_classPrivateFieldSet2(_context, this, new EjsContext(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_methods, this)));
|
|
814
|
+
_classPrivateFieldSet2(_compiler, this, new EjsCompiler(_classPrivateFieldGet2(_config, this)));
|
|
815
|
+
_classPrivateFieldSet2(_cache, this, new EjsCache(_classPrivateFieldGet2(_config, this)));
|
|
816
|
+
_classPrivateFieldSet2(_template, this, new EjsTemplate(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_cache, this), _classPrivateFieldGet2(_compiler, this)));
|
|
817
|
+
this.helpers({
|
|
818
|
+
render: this.render,
|
|
819
|
+
require: this.require
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
create(options) {
|
|
823
|
+
return new this.constructor(options);
|
|
824
|
+
}
|
|
825
|
+
configure(options) {
|
|
826
|
+
if (options) {
|
|
827
|
+
configSchema(_classPrivateFieldGet2(_config, this), options);
|
|
828
|
+
_classPrivateFieldGet2(_context, this).configure(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_methods, this));
|
|
829
|
+
_classPrivateFieldGet2(_compiler, this).configure(_classPrivateFieldGet2(_config, this));
|
|
830
|
+
_classPrivateFieldGet2(_cache, this).configure(_classPrivateFieldGet2(_config, this));
|
|
831
|
+
_classPrivateFieldGet2(_template, this).configure(_classPrivateFieldGet2(_config, this));
|
|
832
|
+
}
|
|
833
|
+
return _classPrivateFieldGet2(_config, this);
|
|
834
|
+
}
|
|
835
|
+
createContext(data) {
|
|
836
|
+
return _classPrivateFieldGet2(_context, this).create(data);
|
|
837
|
+
}
|
|
838
|
+
preload(list) {
|
|
839
|
+
return _classPrivateFieldGet2(_cache, this).load(list || {});
|
|
840
|
+
}
|
|
841
|
+
compile(content, path) {
|
|
842
|
+
return _classPrivateFieldGet2(_compiler, this).compile(content, path);
|
|
843
|
+
}
|
|
844
|
+
helpers(methods) {
|
|
845
|
+
_classPrivateFieldGet2(_context, this).helpers(Object.assign(_classPrivateFieldGet2(_methods, this), methods));
|
|
846
|
+
}
|
|
847
|
+
async render(name, params) {
|
|
848
|
+
const data = this.createContext(params);
|
|
849
|
+
return _assertClassBrand(_EjsInstance_brand, this, _output).call(this, _assertClassBrand(_EjsInstance_brand, this, _path).call(this, name), data).then(_assertClassBrand(_EjsInstance_brand, this, _outputContent).call(this, name, data));
|
|
850
|
+
}
|
|
851
|
+
async require(name) {
|
|
852
|
+
const data = this.createContext({});
|
|
853
|
+
return _assertClassBrand(_EjsInstance_brand, this, _output).call(this, _assertClassBrand(_EjsInstance_brand, this, _path).call(this, name), data).then(() => data.getMacro());
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
function _path(name) {
|
|
857
|
+
const ext = name.split('.').pop();
|
|
858
|
+
if (ext !== _classPrivateFieldGet2(_config, this).extension) {
|
|
859
|
+
name = [name, _classPrivateFieldGet2(_config, this).extension].join('.');
|
|
860
|
+
}
|
|
861
|
+
return name;
|
|
862
|
+
}
|
|
863
|
+
function _output(path, data) {
|
|
864
|
+
return _classPrivateFieldGet2(_template, this).get(path).then(callback => callback.apply(data, [data, data.useComponent(), data.useElement(), data.useBuffer(), data.useEscapeValue()]));
|
|
865
|
+
}
|
|
866
|
+
function _renderLayout(name, params, parentTemplate) {
|
|
867
|
+
const data = this.createContext(params);
|
|
868
|
+
if (parentTemplate) data.setParentTemplate(parentTemplate);
|
|
869
|
+
return _assertClassBrand(_EjsInstance_brand, this, _output).call(this, _assertClassBrand(_EjsInstance_brand, this, _path).call(this, name), data).then(_assertClassBrand(_EjsInstance_brand, this, _outputContent).call(this, name, data));
|
|
870
|
+
}
|
|
871
|
+
function _outputContent(name, data) {
|
|
872
|
+
return content => {
|
|
873
|
+
if (data.getExtend()) {
|
|
874
|
+
data.setExtend(false);
|
|
875
|
+
return _assertClassBrand(_EjsInstance_brand, this, _renderLayout).call(this, data.getLayout(), data, name);
|
|
876
|
+
}
|
|
877
|
+
return content;
|
|
791
878
|
};
|
|
879
|
+
}
|
|
880
|
+
_defineProperty(EjsInstance, "exports", ['configure', 'create', 'createContext', 'render', 'require', 'preload', 'compile', 'helpers']);
|
|
792
881
|
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
882
|
+
const resolver = async (path, template, error) => {
|
|
883
|
+
return fetch(joinPath(path, template)).then(response => {
|
|
884
|
+
if (response.ok) return response.text();
|
|
885
|
+
return error(1, "template ".concat(template, " not found"));
|
|
886
|
+
}, reason => error(0, reason));
|
|
887
|
+
};
|
|
888
|
+
const {
|
|
889
|
+
render,
|
|
890
|
+
configure,
|
|
891
|
+
create,
|
|
892
|
+
helpers,
|
|
893
|
+
createContext,
|
|
894
|
+
compile,
|
|
895
|
+
preload
|
|
896
|
+
} = new EjsInstance({
|
|
897
|
+
resolver
|
|
898
|
+
});
|
|
804
899
|
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
900
|
+
exports.compile = compile;
|
|
901
|
+
exports.configure = configure;
|
|
902
|
+
exports.create = create;
|
|
903
|
+
exports.createContext = createContext;
|
|
904
|
+
exports.helpers = helpers;
|
|
905
|
+
exports.preload = preload;
|
|
906
|
+
exports.render = render;
|
|
812
907
|
|
|
813
908
|
}));
|