@kosatyi/ejs 0.0.97 → 0.0.99
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 +778 -645
- package/dist/cjs/bundler.js +28 -22
- package/dist/cjs/element.js +7 -0
- package/dist/cjs/index.js +787 -653
- package/dist/cjs/worker.js +774 -643
- package/dist/esm/browser.js +557 -616
- package/dist/esm/bundler.js +21 -15
- package/dist/esm/element.js +11 -1
- package/dist/esm/index.js +566 -625
- package/dist/esm/worker.js +573 -633
- package/dist/umd/browser.js +996 -863
- package/dist/umd/browser.min.js +1 -1
- package/dist/umd/element.js +7 -0
- package/dist/umd/index.js +1030 -896
- package/dist/umd/index.min.js +1 -1
- package/dist/umd/worker.js +774 -643
- package/dist/umd/worker.min.js +1 -1
- package/package.json +1 -1
- package/types/ejs.d.ts +26 -26
- package/types/global.d.ts +4 -0
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,141 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var fs = require('fs');
|
|
4
|
-
var path = require('path');
|
|
3
|
+
var fs = require('node:fs');
|
|
4
|
+
var path = require('node:path');
|
|
5
|
+
|
|
6
|
+
function _assertClassBrand(e, t, n) {
|
|
7
|
+
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
8
|
+
throw new TypeError("Private element is not present on this object");
|
|
9
|
+
}
|
|
10
|
+
function _assertThisInitialized(e) {
|
|
11
|
+
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
12
|
+
return e;
|
|
13
|
+
}
|
|
14
|
+
function _callSuper(t, o, e) {
|
|
15
|
+
return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
|
|
16
|
+
}
|
|
17
|
+
function _checkPrivateRedeclaration(e, t) {
|
|
18
|
+
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
19
|
+
}
|
|
20
|
+
function _classCallCheck(a, n) {
|
|
21
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
22
|
+
}
|
|
23
|
+
function _classPrivateFieldGet2(s, a) {
|
|
24
|
+
return s.get(_assertClassBrand(s, a));
|
|
25
|
+
}
|
|
26
|
+
function _classPrivateFieldInitSpec(e, t, a) {
|
|
27
|
+
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
28
|
+
}
|
|
29
|
+
function _classPrivateFieldSet2(s, a, r) {
|
|
30
|
+
return s.set(_assertClassBrand(s, a), r), r;
|
|
31
|
+
}
|
|
32
|
+
function _classPrivateMethodInitSpec(e, a) {
|
|
33
|
+
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
34
|
+
}
|
|
35
|
+
function _construct(t, e, r) {
|
|
36
|
+
if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
|
|
37
|
+
var o = [null];
|
|
38
|
+
o.push.apply(o, e);
|
|
39
|
+
var p = new (t.bind.apply(t, o))();
|
|
40
|
+
return r && _setPrototypeOf(p, r.prototype), p;
|
|
41
|
+
}
|
|
42
|
+
function _defineProperties(e, r) {
|
|
43
|
+
for (var t = 0; t < r.length; t++) {
|
|
44
|
+
var o = r[t];
|
|
45
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function _createClass(e, r, t) {
|
|
49
|
+
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
|
|
50
|
+
writable: !1
|
|
51
|
+
}), e;
|
|
52
|
+
}
|
|
53
|
+
function _defineProperty(e, r, t) {
|
|
54
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
55
|
+
value: t,
|
|
56
|
+
enumerable: !0,
|
|
57
|
+
configurable: !0,
|
|
58
|
+
writable: !0
|
|
59
|
+
}) : e[r] = t, e;
|
|
60
|
+
}
|
|
61
|
+
function _getPrototypeOf(t) {
|
|
62
|
+
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
63
|
+
return t.__proto__ || Object.getPrototypeOf(t);
|
|
64
|
+
}, _getPrototypeOf(t);
|
|
65
|
+
}
|
|
66
|
+
function _inherits(t, e) {
|
|
67
|
+
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
68
|
+
t.prototype = Object.create(e && e.prototype, {
|
|
69
|
+
constructor: {
|
|
70
|
+
value: t,
|
|
71
|
+
writable: !0,
|
|
72
|
+
configurable: !0
|
|
73
|
+
}
|
|
74
|
+
}), Object.defineProperty(t, "prototype", {
|
|
75
|
+
writable: !1
|
|
76
|
+
}), e && _setPrototypeOf(t, e);
|
|
77
|
+
}
|
|
78
|
+
function _isNativeFunction(t) {
|
|
79
|
+
try {
|
|
80
|
+
return -1 !== Function.toString.call(t).indexOf("[native code]");
|
|
81
|
+
} catch (n) {
|
|
82
|
+
return "function" == typeof t;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function _isNativeReflectConstruct() {
|
|
86
|
+
try {
|
|
87
|
+
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
88
|
+
} catch (t) {}
|
|
89
|
+
return (_isNativeReflectConstruct = function () {
|
|
90
|
+
return !!t;
|
|
91
|
+
})();
|
|
92
|
+
}
|
|
93
|
+
function _possibleConstructorReturn(t, e) {
|
|
94
|
+
if (e && ("object" == typeof e || "function" == typeof e)) return e;
|
|
95
|
+
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
96
|
+
return _assertThisInitialized(t);
|
|
97
|
+
}
|
|
98
|
+
function _setPrototypeOf(t, e) {
|
|
99
|
+
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
100
|
+
return t.__proto__ = e, t;
|
|
101
|
+
}, _setPrototypeOf(t, e);
|
|
102
|
+
}
|
|
103
|
+
function _toPrimitive(t, r) {
|
|
104
|
+
if ("object" != typeof t || !t) return t;
|
|
105
|
+
var e = t[Symbol.toPrimitive];
|
|
106
|
+
if (void 0 !== e) {
|
|
107
|
+
var i = e.call(t, r);
|
|
108
|
+
if ("object" != typeof i) return i;
|
|
109
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
110
|
+
}
|
|
111
|
+
return (String )(t);
|
|
112
|
+
}
|
|
113
|
+
function _toPropertyKey(t) {
|
|
114
|
+
var i = _toPrimitive(t, "string");
|
|
115
|
+
return "symbol" == typeof i ? i : i + "";
|
|
116
|
+
}
|
|
117
|
+
function _wrapNativeSuper(t) {
|
|
118
|
+
var r = "function" == typeof Map ? new Map() : void 0;
|
|
119
|
+
return _wrapNativeSuper = function (t) {
|
|
120
|
+
if (null === t || !_isNativeFunction(t)) return t;
|
|
121
|
+
if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function");
|
|
122
|
+
if (void 0 !== r) {
|
|
123
|
+
if (r.has(t)) return r.get(t);
|
|
124
|
+
r.set(t, Wrapper);
|
|
125
|
+
}
|
|
126
|
+
function Wrapper() {
|
|
127
|
+
return _construct(t, arguments, _getPrototypeOf(this).constructor);
|
|
128
|
+
}
|
|
129
|
+
return Wrapper.prototype = Object.create(t.prototype, {
|
|
130
|
+
constructor: {
|
|
131
|
+
value: Wrapper,
|
|
132
|
+
enumerable: !1,
|
|
133
|
+
writable: !0,
|
|
134
|
+
configurable: !0
|
|
135
|
+
}
|
|
136
|
+
}), _setPrototypeOf(Wrapper, t);
|
|
137
|
+
}, _wrapNativeSuper(t);
|
|
138
|
+
}
|
|
5
139
|
|
|
6
140
|
var typeProp = function typeProp() {
|
|
7
141
|
var args = [].slice.call(arguments);
|
|
@@ -67,6 +201,9 @@ var safeValue = function safeValue(value, escape) {
|
|
|
67
201
|
var instanceOf = function instanceOf(object, instance) {
|
|
68
202
|
return Boolean(object instanceof instance);
|
|
69
203
|
};
|
|
204
|
+
var assertInstanceOf = function assertInstanceOf(object, instance) {
|
|
205
|
+
if (instanceOf(object, instance) === false) throw new TypeError("".concat(object, " in not instance of ").concat(instance));
|
|
206
|
+
};
|
|
70
207
|
var getPath = function getPath(context, name, strict) {
|
|
71
208
|
var data = context;
|
|
72
209
|
var chunks = String(name).split('.');
|
|
@@ -87,6 +224,14 @@ var getPath = function getPath(context, name, strict) {
|
|
|
87
224
|
}
|
|
88
225
|
return [data, prop];
|
|
89
226
|
};
|
|
227
|
+
var bindContext = function bindContext(object) {
|
|
228
|
+
var methods = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
229
|
+
methods.forEach(function (name) {
|
|
230
|
+
if (name in object) {
|
|
231
|
+
object[name] = object[name].bind(object);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
};
|
|
90
235
|
var ext = function ext(path, defaults) {
|
|
91
236
|
var ext = path.split('.').pop();
|
|
92
237
|
if (ext !== defaults) {
|
|
@@ -149,6 +294,13 @@ var omit = function omit(object, list) {
|
|
|
149
294
|
}
|
|
150
295
|
});
|
|
151
296
|
};
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
*
|
|
300
|
+
* @param object
|
|
301
|
+
* @param prop
|
|
302
|
+
* @return {boolean}
|
|
303
|
+
*/
|
|
152
304
|
var hasProp = function hasProp(object, prop) {
|
|
153
305
|
return object && object.hasOwnProperty(prop);
|
|
154
306
|
};
|
|
@@ -157,6 +309,17 @@ var joinPath = function joinPath(path, template) {
|
|
|
157
309
|
template = template.replace(/\/\//g, '/');
|
|
158
310
|
return template;
|
|
159
311
|
};
|
|
312
|
+
var matchTokens = function matchTokens(regex, text, callback) {
|
|
313
|
+
var index = 0;
|
|
314
|
+
text.replace(regex, function () {
|
|
315
|
+
var params = [].slice.call(arguments, 0, -1);
|
|
316
|
+
var offset = params.pop();
|
|
317
|
+
var match = params.shift();
|
|
318
|
+
callback(params, index, offset);
|
|
319
|
+
index = offset + match.length;
|
|
320
|
+
return match;
|
|
321
|
+
});
|
|
322
|
+
};
|
|
160
323
|
|
|
161
324
|
var defaults = {};
|
|
162
325
|
defaults["export"] = 'ejsPrecompiled';
|
|
@@ -173,6 +336,7 @@ defaults.globalHelpers = [];
|
|
|
173
336
|
defaults.vars = {
|
|
174
337
|
SCOPE: 'ejs',
|
|
175
338
|
COMPONENT: 'ui',
|
|
339
|
+
ELEMENT: 'el',
|
|
176
340
|
EXTEND: '$$e',
|
|
177
341
|
BUFFER: '$$a',
|
|
178
342
|
LAYOUT: '$$l',
|
|
@@ -202,206 +366,219 @@ var configSchema = function configSchema(config, options) {
|
|
|
202
366
|
};
|
|
203
367
|
|
|
204
368
|
var global = typeof globalThis !== 'undefined' ? globalThis : window || self;
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
369
|
+
var _enabled = /*#__PURE__*/new WeakMap();
|
|
370
|
+
var _list = /*#__PURE__*/new WeakMap();
|
|
371
|
+
var Cache = /*#__PURE__*/function () {
|
|
372
|
+
function Cache(config) {
|
|
373
|
+
_classCallCheck(this, Cache);
|
|
374
|
+
_classPrivateFieldInitSpec(this, _enabled, true);
|
|
375
|
+
_classPrivateFieldInitSpec(this, _list, {});
|
|
376
|
+
this.configure(config);
|
|
377
|
+
}
|
|
378
|
+
return _createClass(Cache, [{
|
|
379
|
+
key: "load",
|
|
380
|
+
value: function load(data) {
|
|
381
|
+
if (_classPrivateFieldGet2(_enabled, this)) {
|
|
382
|
+
extend(_classPrivateFieldGet2(_list, this), data || {});
|
|
383
|
+
}
|
|
215
384
|
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
extend(cache.list, data || {});
|
|
385
|
+
}, {
|
|
386
|
+
key: "get",
|
|
387
|
+
value: function get(key) {
|
|
388
|
+
if (_classPrivateFieldGet2(_enabled, this)) {
|
|
389
|
+
return _classPrivateFieldGet2(_list, this)[key];
|
|
390
|
+
}
|
|
223
391
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
392
|
+
}, {
|
|
393
|
+
key: "set",
|
|
394
|
+
value: function set(key, value) {
|
|
395
|
+
if (_classPrivateFieldGet2(_enabled, this)) {
|
|
396
|
+
_classPrivateFieldGet2(_list, this)[key] = value;
|
|
397
|
+
}
|
|
229
398
|
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
399
|
+
}, {
|
|
400
|
+
key: "exist",
|
|
401
|
+
value: function exist(key) {
|
|
402
|
+
return hasProp(_classPrivateFieldGet2(_list, this), key);
|
|
234
403
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
|
|
404
|
+
}, {
|
|
405
|
+
key: "clear",
|
|
406
|
+
value: function clear() {
|
|
407
|
+
_classPrivateFieldSet2(_list, this, {});
|
|
408
|
+
}
|
|
409
|
+
}, {
|
|
410
|
+
key: "remove",
|
|
411
|
+
value: function remove(key) {
|
|
412
|
+
delete _classPrivateFieldGet2(_list, this)[key];
|
|
413
|
+
}
|
|
414
|
+
}, {
|
|
415
|
+
key: "resolve",
|
|
416
|
+
value: function resolve(key) {
|
|
417
|
+
return Promise.resolve(this.get(key));
|
|
418
|
+
}
|
|
419
|
+
}, {
|
|
420
|
+
key: "configure",
|
|
421
|
+
value: function configure(config) {
|
|
422
|
+
_classPrivateFieldSet2(_enabled, this, config.cache);
|
|
423
|
+
if (isNode() === false) {
|
|
424
|
+
this.load(global[config["export"]]);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}]);
|
|
428
|
+
}();
|
|
247
429
|
|
|
248
|
-
var
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
430
|
+
var _config$1 = /*#__PURE__*/new WeakMap();
|
|
431
|
+
var _symbols = /*#__PURE__*/new WeakMap();
|
|
432
|
+
var Compiler = /*#__PURE__*/function () {
|
|
433
|
+
function Compiler(config) {
|
|
434
|
+
_classCallCheck(this, Compiler);
|
|
435
|
+
_classPrivateFieldInitSpec(this, _config$1, {});
|
|
436
|
+
_classPrivateFieldInitSpec(this, _symbols, [{
|
|
437
|
+
symbol: '-',
|
|
438
|
+
format: function format(value) {
|
|
439
|
+
return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, ",1))\n").concat(this.BUFFER, "('");
|
|
440
|
+
}
|
|
441
|
+
}, {
|
|
442
|
+
symbol: '=',
|
|
443
|
+
format: function format(value) {
|
|
444
|
+
return "')\n".concat(this.BUFFER, "(").concat(this.SAFE, "(").concat(value, "))\n").concat(this.BUFFER, "('");
|
|
445
|
+
}
|
|
446
|
+
}, {
|
|
447
|
+
symbol: '#',
|
|
448
|
+
format: function format(value) {
|
|
449
|
+
return "')\n/**".concat(value, "**/\n").concat(this.BUFFER, "('");
|
|
450
|
+
}
|
|
451
|
+
}, {
|
|
452
|
+
symbol: '',
|
|
453
|
+
format: function format(value) {
|
|
454
|
+
return "')\n".concat(value.trim(), "\n").concat(this.BUFFER, "('");
|
|
455
|
+
}
|
|
456
|
+
}]);
|
|
457
|
+
this.configure(config);
|
|
267
458
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
compiler.vars = config.vars;
|
|
288
|
-
compiler.globalHelpers = config.globalHelpers;
|
|
289
|
-
compiler.matches = [];
|
|
290
|
-
compiler.formats = [];
|
|
291
|
-
compiler.slurp = {
|
|
292
|
-
match: '[\s\t\n]*',
|
|
293
|
-
start: [compiler.token.start, '_'],
|
|
294
|
-
end: ['_', compiler.token.end]
|
|
295
|
-
};
|
|
296
|
-
tagList.forEach(function (item) {
|
|
297
|
-
compiler.matches.push(compiler.token.start.concat(item.symbol).concat(compiler.token.regex).concat(compiler.token.end));
|
|
298
|
-
compiler.formats.push(item.format.bind(compiler.vars));
|
|
299
|
-
});
|
|
300
|
-
compiler.regex = new RegExp(compiler.matches.join('|').concat('|$'), 'g');
|
|
301
|
-
compiler.slurpStart = new RegExp([compiler.slurp.match, compiler.slurp.start.join('')].join(''), 'gm');
|
|
302
|
-
compiler.slurpEnd = new RegExp([compiler.slurp.end.join(''), compiler.slurp.match].join(''), 'gm');
|
|
303
|
-
};
|
|
304
|
-
this.compile = function (content, path) {
|
|
305
|
-
var _compiler$vars = compiler.vars,
|
|
306
|
-
SCOPE = _compiler$vars.SCOPE,
|
|
307
|
-
SAFE = _compiler$vars.SAFE,
|
|
308
|
-
BUFFER = _compiler$vars.BUFFER,
|
|
309
|
-
COMPONENT = _compiler$vars.COMPONENT;
|
|
310
|
-
var GLOBALS = compiler.globalHelpers;
|
|
311
|
-
content = String(content);
|
|
312
|
-
if (compiler.rmWhitespace) {
|
|
313
|
-
content = content.replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
|
|
314
|
-
}
|
|
315
|
-
content = content.replace(compiler.slurpStart, compiler.token.start).replace(compiler.slurpEnd, compiler.token.end);
|
|
316
|
-
var source = "".concat(BUFFER, "('");
|
|
317
|
-
matchTokens(compiler.regex, content, function (params, index, offset) {
|
|
318
|
-
source += symbols(content.slice(index, offset));
|
|
319
|
-
params.forEach(function (value, index) {
|
|
320
|
-
if (value) {
|
|
321
|
-
source += compiler.formats[index](value);
|
|
322
|
-
}
|
|
459
|
+
return _createClass(Compiler, [{
|
|
460
|
+
key: "configure",
|
|
461
|
+
value: function configure(config) {
|
|
462
|
+
var _this = this;
|
|
463
|
+
_classPrivateFieldGet2(_config$1, this).withObject = config.withObject;
|
|
464
|
+
_classPrivateFieldGet2(_config$1, this).rmWhitespace = config.rmWhitespace;
|
|
465
|
+
_classPrivateFieldGet2(_config$1, this).token = config.token;
|
|
466
|
+
_classPrivateFieldGet2(_config$1, this).vars = config.vars;
|
|
467
|
+
_classPrivateFieldGet2(_config$1, this).globalHelpers = config.globalHelpers;
|
|
468
|
+
_classPrivateFieldGet2(_config$1, this).matches = [];
|
|
469
|
+
_classPrivateFieldGet2(_config$1, this).formats = [];
|
|
470
|
+
_classPrivateFieldGet2(_config$1, this).slurp = {
|
|
471
|
+
match: '[s\t\n]*',
|
|
472
|
+
start: [_classPrivateFieldGet2(_config$1, this).token.start, '_'],
|
|
473
|
+
end: ['_', _classPrivateFieldGet2(_config$1, this).token.end]
|
|
474
|
+
};
|
|
475
|
+
_classPrivateFieldGet2(_symbols, this).forEach(function (item) {
|
|
476
|
+
_classPrivateFieldGet2(_config$1, _this).matches.push(_classPrivateFieldGet2(_config$1, _this).token.start.concat(item.symbol).concat(_classPrivateFieldGet2(_config$1, _this).token.regex).concat(_classPrivateFieldGet2(_config$1, _this).token.end));
|
|
477
|
+
_classPrivateFieldGet2(_config$1, _this).formats.push(item.format.bind(_classPrivateFieldGet2(_config$1, _this).vars));
|
|
323
478
|
});
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
if (compiler.withObject) {
|
|
328
|
-
source = "with(".concat(SCOPE, "){").concat(source, "}");
|
|
329
|
-
}
|
|
330
|
-
source = "".concat(BUFFER, ".start();").concat(source, "return ").concat(BUFFER, ".end();");
|
|
331
|
-
source += "\n//# sourceURL=".concat(path);
|
|
332
|
-
var result = null;
|
|
333
|
-
var params = [SCOPE, COMPONENT, BUFFER, SAFE].concat(GLOBALS);
|
|
334
|
-
try {
|
|
335
|
-
result = Function.apply(null, params.concat(source));
|
|
336
|
-
result.source = "(function(".concat(params.join(','), "){\n").concat(source, "\n});");
|
|
337
|
-
} catch (e) {
|
|
338
|
-
e.filename = path;
|
|
339
|
-
e.source = source;
|
|
340
|
-
throw e;
|
|
341
|
-
}
|
|
342
|
-
return result;
|
|
343
|
-
};
|
|
344
|
-
this.configure(config);
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
function Template(config, cache, compiler) {
|
|
348
|
-
if (instanceOf(this, Template) === false) return new Template(config, cache, compiler);
|
|
349
|
-
if (instanceOf(cache, Cache) === false) throw new TypeError('cache is not instance of Cache');
|
|
350
|
-
if (instanceOf(compiler, Compiler) === false) throw new TypeError('compiler is not instance of Compiler');
|
|
351
|
-
var template = {};
|
|
352
|
-
var result = function result(template, content) {
|
|
353
|
-
cache.set(template, content);
|
|
354
|
-
return content;
|
|
355
|
-
};
|
|
356
|
-
var resolve = function resolve(path) {
|
|
357
|
-
return template.resolver(template.path, path);
|
|
358
|
-
};
|
|
359
|
-
var compile = function compile(content, template) {
|
|
360
|
-
if (isFunction(content)) {
|
|
361
|
-
return content;
|
|
362
|
-
} else {
|
|
363
|
-
return compiler.compile(content, template);
|
|
479
|
+
_classPrivateFieldGet2(_config$1, this).regex = new RegExp(_classPrivateFieldGet2(_config$1, this).matches.join('|').concat('|$'), 'g');
|
|
480
|
+
_classPrivateFieldGet2(_config$1, this).slurpStart = new RegExp([_classPrivateFieldGet2(_config$1, this).slurp.match, _classPrivateFieldGet2(_config$1, this).slurp.start.join('')].join(''), 'gm');
|
|
481
|
+
_classPrivateFieldGet2(_config$1, this).slurpEnd = new RegExp([_classPrivateFieldGet2(_config$1, this).slurp.end.join(''), _classPrivateFieldGet2(_config$1, this).slurp.match].join(''), 'gm');
|
|
364
482
|
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
483
|
+
}, {
|
|
484
|
+
key: "compile",
|
|
485
|
+
value: function compile(content, path) {
|
|
486
|
+
var _this2 = this;
|
|
487
|
+
var _classPrivateFieldGet2$1 = _classPrivateFieldGet2(_config$1, this).vars,
|
|
488
|
+
SCOPE = _classPrivateFieldGet2$1.SCOPE,
|
|
489
|
+
SAFE = _classPrivateFieldGet2$1.SAFE,
|
|
490
|
+
BUFFER = _classPrivateFieldGet2$1.BUFFER,
|
|
491
|
+
COMPONENT = _classPrivateFieldGet2$1.COMPONENT,
|
|
492
|
+
ELEMENT = _classPrivateFieldGet2$1.ELEMENT;
|
|
493
|
+
var GLOBALS = _classPrivateFieldGet2(_config$1, this).globalHelpers;
|
|
494
|
+
if (_classPrivateFieldGet2(_config$1, this).rmWhitespace) {
|
|
495
|
+
content = String(content).replace(/[\r\n]+/g, '\n').replace(/^\s+|\s+$/gm, '');
|
|
496
|
+
}
|
|
497
|
+
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);
|
|
498
|
+
var source = "".concat(BUFFER, "('");
|
|
499
|
+
matchTokens(_classPrivateFieldGet2(_config$1, this).regex, content, function (params, index, offset) {
|
|
500
|
+
source += symbols(content.slice(index, offset));
|
|
501
|
+
params.forEach(function (value, index) {
|
|
502
|
+
if (value) {
|
|
503
|
+
source += _classPrivateFieldGet2(_config$1, _this2).formats[index](value);
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
});
|
|
507
|
+
source += "');";
|
|
508
|
+
source = "try{".concat(source, "}catch(e){return ").concat(BUFFER, ".error(e)}");
|
|
509
|
+
if (_classPrivateFieldGet2(_config$1, this).withObject) {
|
|
510
|
+
source = "with(".concat(SCOPE, "){").concat(source, "}");
|
|
511
|
+
}
|
|
512
|
+
source = "".concat(BUFFER, ".start();").concat(source, "return ").concat(BUFFER, ".end();");
|
|
513
|
+
source += "\n//# sourceURL=".concat(path);
|
|
514
|
+
var result = null;
|
|
515
|
+
var params = [SCOPE, BUFFER, SAFE, COMPONENT, ELEMENT].concat(GLOBALS);
|
|
516
|
+
try {
|
|
517
|
+
result = Function.apply(null, params.concat(source));
|
|
518
|
+
result.source = "(function(".concat(params.join(','), "){\n").concat(source, "\n});");
|
|
519
|
+
} catch (e) {
|
|
520
|
+
e.filename = path;
|
|
521
|
+
e.source = source;
|
|
522
|
+
throw e;
|
|
523
|
+
}
|
|
524
|
+
return result;
|
|
371
525
|
}
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
526
|
+
}]);
|
|
527
|
+
}();
|
|
528
|
+
|
|
529
|
+
var _path = /*#__PURE__*/new WeakMap();
|
|
530
|
+
var _cache$1 = /*#__PURE__*/new WeakMap();
|
|
531
|
+
var _compiler$1 = /*#__PURE__*/new WeakMap();
|
|
532
|
+
var _resolver = /*#__PURE__*/new WeakMap();
|
|
533
|
+
var _Template_brand = /*#__PURE__*/new WeakSet();
|
|
534
|
+
var Template = /*#__PURE__*/function () {
|
|
535
|
+
function Template(config, cache, compiler) {
|
|
536
|
+
_classCallCheck(this, Template);
|
|
537
|
+
_classPrivateMethodInitSpec(this, _Template_brand);
|
|
538
|
+
_classPrivateFieldInitSpec(this, _path, void 0);
|
|
539
|
+
_classPrivateFieldInitSpec(this, _cache$1, void 0);
|
|
540
|
+
_classPrivateFieldInitSpec(this, _compiler$1, void 0);
|
|
541
|
+
_classPrivateFieldInitSpec(this, _resolver, void 0);
|
|
542
|
+
assertInstanceOf(cache, Cache);
|
|
543
|
+
assertInstanceOf(compiler, Compiler);
|
|
544
|
+
_classPrivateFieldSet2(_cache$1, this, cache);
|
|
545
|
+
_classPrivateFieldSet2(_compiler$1, this, compiler);
|
|
546
|
+
this.configure(config);
|
|
547
|
+
}
|
|
548
|
+
return _createClass(Template, [{
|
|
549
|
+
key: "configure",
|
|
550
|
+
value: function configure(config) {
|
|
551
|
+
_classPrivateFieldSet2(_path, this, config.path);
|
|
552
|
+
if (isFunction(config.resolver)) {
|
|
553
|
+
_classPrivateFieldSet2(_resolver, this, config.resolver);
|
|
554
|
+
}
|
|
376
555
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
556
|
+
}, {
|
|
557
|
+
key: "get",
|
|
558
|
+
value: function get(template) {
|
|
559
|
+
var _this = this;
|
|
560
|
+
if (_classPrivateFieldGet2(_cache$1, this).exist(template)) {
|
|
561
|
+
return _classPrivateFieldGet2(_cache$1, this).resolve(template);
|
|
562
|
+
}
|
|
563
|
+
return _assertClassBrand(_Template_brand, this, _resolve).call(this, template).then(function (content) {
|
|
564
|
+
return _assertClassBrand(_Template_brand, _this, _result).call(_this, template, _assertClassBrand(_Template_brand, _this, _compile).call(_this, content, template));
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
}]);
|
|
568
|
+
}();
|
|
569
|
+
function _resolve(path) {
|
|
570
|
+
return _classPrivateFieldGet2(_resolver, this).call(this, _classPrivateFieldGet2(_path, this), path);
|
|
382
571
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
return
|
|
386
|
-
value: t,
|
|
387
|
-
enumerable: !0,
|
|
388
|
-
configurable: !0,
|
|
389
|
-
writable: !0
|
|
390
|
-
}) : e[r] = t, e;
|
|
572
|
+
function _result(template, content) {
|
|
573
|
+
_classPrivateFieldGet2(_cache$1, this).set(template, content);
|
|
574
|
+
return content;
|
|
391
575
|
}
|
|
392
|
-
function
|
|
393
|
-
if (
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
if ("object" != typeof i) return i;
|
|
398
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
576
|
+
function _compile(content, template) {
|
|
577
|
+
if (isFunction(content)) {
|
|
578
|
+
return content;
|
|
579
|
+
} else {
|
|
580
|
+
return _classPrivateFieldGet2(_compiler$1, this).compile(content, template);
|
|
399
581
|
}
|
|
400
|
-
return ("string" === r ? String : Number)(t);
|
|
401
|
-
}
|
|
402
|
-
function _toPropertyKey(t) {
|
|
403
|
-
var i = _toPrimitive(t, "string");
|
|
404
|
-
return "symbol" == typeof i ? i : i + "";
|
|
405
582
|
}
|
|
406
583
|
|
|
407
584
|
var selfClosed = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
|
|
@@ -429,82 +606,61 @@ var element = function element(tag, attrs, content) {
|
|
|
429
606
|
return result.join('');
|
|
430
607
|
};
|
|
431
608
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
};
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
Object.assign(TemplateNotFound.prototype, {
|
|
488
|
-
code: 404
|
|
489
|
-
});
|
|
490
|
-
/**
|
|
491
|
-
* @extends TemplateError
|
|
492
|
-
* @param {string} message
|
|
493
|
-
* @constructor
|
|
494
|
-
*/
|
|
495
|
-
function TemplateSyntaxError(message) {
|
|
496
|
-
TemplateError.call(this);
|
|
497
|
-
this.name = 'TemplateSyntaxError';
|
|
498
|
-
this.message = message;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
/**
|
|
502
|
-
*
|
|
503
|
-
*/
|
|
504
|
-
Object.setPrototypeOf(TemplateSyntaxError.prototype, TemplateError.prototype);
|
|
505
|
-
Object.assign(TemplateSyntaxError.prototype, {
|
|
506
|
-
code: 500
|
|
507
|
-
});
|
|
609
|
+
var TemplateError = /*#__PURE__*/function (_Error) {
|
|
610
|
+
function TemplateError(message) {
|
|
611
|
+
var _this;
|
|
612
|
+
_classCallCheck(this, TemplateError);
|
|
613
|
+
_this = _callSuper(this, TemplateError);
|
|
614
|
+
_defineProperty(_this, "code", 0);
|
|
615
|
+
_this.message = message;
|
|
616
|
+
return _this;
|
|
617
|
+
}
|
|
618
|
+
_inherits(TemplateError, _Error);
|
|
619
|
+
return _createClass(TemplateError, [{
|
|
620
|
+
key: "getCode",
|
|
621
|
+
value: function getCode() {
|
|
622
|
+
return this.code;
|
|
623
|
+
}
|
|
624
|
+
}, {
|
|
625
|
+
key: "getMessage",
|
|
626
|
+
value: function getMessage() {
|
|
627
|
+
return this.message;
|
|
628
|
+
}
|
|
629
|
+
}, {
|
|
630
|
+
key: "toString",
|
|
631
|
+
value: function toString() {
|
|
632
|
+
return this.getMessage();
|
|
633
|
+
}
|
|
634
|
+
}]);
|
|
635
|
+
}(/*#__PURE__*/_wrapNativeSuper(Error));
|
|
636
|
+
var TemplateNotFound = /*#__PURE__*/function (_TemplateError2) {
|
|
637
|
+
function TemplateNotFound() {
|
|
638
|
+
var _this2;
|
|
639
|
+
_classCallCheck(this, TemplateNotFound);
|
|
640
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
641
|
+
args[_key] = arguments[_key];
|
|
642
|
+
}
|
|
643
|
+
_this2 = _callSuper(this, TemplateNotFound, [].concat(args));
|
|
644
|
+
_defineProperty(_this2, "code", 404);
|
|
645
|
+
return _this2;
|
|
646
|
+
}
|
|
647
|
+
_inherits(TemplateNotFound, _TemplateError2);
|
|
648
|
+
return _createClass(TemplateNotFound);
|
|
649
|
+
}(TemplateError);
|
|
650
|
+
var TemplateSyntaxError = /*#__PURE__*/function (_TemplateError3) {
|
|
651
|
+
function TemplateSyntaxError() {
|
|
652
|
+
var _this3;
|
|
653
|
+
_classCallCheck(this, TemplateSyntaxError);
|
|
654
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
655
|
+
args[_key2] = arguments[_key2];
|
|
656
|
+
}
|
|
657
|
+
_this3 = _callSuper(this, TemplateSyntaxError, [].concat(args));
|
|
658
|
+
_defineProperty(_this3, "code", 500);
|
|
659
|
+
return _this3;
|
|
660
|
+
}
|
|
661
|
+
_inherits(TemplateSyntaxError, _TemplateError3);
|
|
662
|
+
return _createClass(TemplateSyntaxError);
|
|
663
|
+
}(TemplateError);
|
|
508
664
|
|
|
509
665
|
function resolve(list) {
|
|
510
666
|
return Promise.all(list || []).then(function (list) {
|
|
@@ -516,12 +672,17 @@ function resolve(list) {
|
|
|
516
672
|
function reject(error) {
|
|
517
673
|
return Promise.reject(new TemplateSyntaxError(error.message));
|
|
518
674
|
}
|
|
675
|
+
|
|
676
|
+
/**
|
|
677
|
+
*
|
|
678
|
+
* @return {buffer}
|
|
679
|
+
*/
|
|
519
680
|
function createBuffer() {
|
|
520
681
|
var store = [],
|
|
521
682
|
array = [];
|
|
522
|
-
function buffer(value) {
|
|
683
|
+
var buffer = function buffer(value) {
|
|
523
684
|
array.push(value);
|
|
524
|
-
}
|
|
685
|
+
};
|
|
525
686
|
buffer.start = function () {
|
|
526
687
|
array = [];
|
|
527
688
|
};
|
|
@@ -543,387 +704,359 @@ function createBuffer() {
|
|
|
543
704
|
return buffer;
|
|
544
705
|
}
|
|
545
706
|
|
|
546
|
-
function
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
configurable: false,
|
|
593
|
-
enumerable: false
|
|
594
|
-
}), EXTEND, {
|
|
595
|
-
value: false,
|
|
596
|
-
writable: true,
|
|
597
|
-
configurable: false,
|
|
598
|
-
enumerable: false
|
|
599
|
-
}), "getMacro", {
|
|
600
|
-
value: function value() {
|
|
601
|
-
return this[MACRO];
|
|
602
|
-
},
|
|
603
|
-
writable: false,
|
|
604
|
-
configurable: false,
|
|
605
|
-
enumerable: false
|
|
606
|
-
}), "getBuffer", {
|
|
607
|
-
value: function value() {
|
|
608
|
-
return this[BUFFER];
|
|
609
|
-
},
|
|
610
|
-
writable: false,
|
|
611
|
-
configurable: false,
|
|
612
|
-
enumerable: false
|
|
613
|
-
}), "getComponent", {
|
|
614
|
-
value: function value() {
|
|
615
|
-
var context = this;
|
|
616
|
-
if (COMPONENT in context) {
|
|
617
|
-
return function () {
|
|
618
|
-
return context[COMPONENT].apply(context, arguments);
|
|
619
|
-
};
|
|
620
|
-
}
|
|
707
|
+
var createContextScope = function createContextScope(config, methods) {
|
|
708
|
+
var _Object$definePropert;
|
|
709
|
+
var _config$vars = config.vars,
|
|
710
|
+
BLOCKS = _config$vars.BLOCKS,
|
|
711
|
+
MACRO = _config$vars.MACRO,
|
|
712
|
+
EXTEND = _config$vars.EXTEND,
|
|
713
|
+
LAYOUT = _config$vars.LAYOUT,
|
|
714
|
+
BUFFER = _config$vars.BUFFER,
|
|
715
|
+
SAFE = _config$vars.SAFE,
|
|
716
|
+
SCOPE = _config$vars.SCOPE,
|
|
717
|
+
COMPONENT = _config$vars.COMPONENT,
|
|
718
|
+
ELEMENT = _config$vars.ELEMENT;
|
|
719
|
+
/**
|
|
720
|
+
* @name ContextScope
|
|
721
|
+
* @param data
|
|
722
|
+
* @constructor
|
|
723
|
+
*/
|
|
724
|
+
function ContextScope(data) {
|
|
725
|
+
this[BLOCKS] = {};
|
|
726
|
+
this[MACRO] = {};
|
|
727
|
+
Object.assign(this, omit(data, [SCOPE, BUFFER, SAFE, COMPONENT, ELEMENT]));
|
|
728
|
+
}
|
|
729
|
+
Object.assign(ContextScope.prototype, methods);
|
|
730
|
+
Object.defineProperties(ContextScope.prototype, (_Object$definePropert = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, BUFFER, {
|
|
731
|
+
value: createBuffer()
|
|
732
|
+
}), BLOCKS, {
|
|
733
|
+
value: {},
|
|
734
|
+
writable: true
|
|
735
|
+
}), MACRO, {
|
|
736
|
+
value: {},
|
|
737
|
+
writable: true
|
|
738
|
+
}), LAYOUT, {
|
|
739
|
+
value: false,
|
|
740
|
+
writable: true
|
|
741
|
+
}), EXTEND, {
|
|
742
|
+
value: false,
|
|
743
|
+
writable: true
|
|
744
|
+
}), "useSafeValue", {
|
|
745
|
+
get: function get() {
|
|
746
|
+
return safeValue;
|
|
747
|
+
}
|
|
748
|
+
}), "useComponent", {
|
|
749
|
+
get: function get() {
|
|
750
|
+
if (isFunction(this[COMPONENT])) {
|
|
751
|
+
return this[COMPONENT].bind(this);
|
|
752
|
+
} else {
|
|
621
753
|
return function () {
|
|
622
|
-
|
|
754
|
+
throw new Error("".concat(COMPONENT, " must be a function"));
|
|
623
755
|
};
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
},
|
|
632
|
-
writable: false,
|
|
633
|
-
configurable: false,
|
|
634
|
-
enumerable: false
|
|
635
|
-
}), "setExtend", {
|
|
636
|
-
value: function value(_value) {
|
|
637
|
-
this[EXTEND] = _value;
|
|
638
|
-
},
|
|
639
|
-
writable: false,
|
|
640
|
-
configurable: false,
|
|
641
|
-
enumerable: false
|
|
642
|
-
}), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "getExtend", {
|
|
643
|
-
value: function value() {
|
|
644
|
-
return this[EXTEND];
|
|
645
|
-
},
|
|
646
|
-
writable: false,
|
|
647
|
-
configurable: false,
|
|
648
|
-
enumerable: false
|
|
649
|
-
}), "setLayout", {
|
|
650
|
-
value: function value(layout) {
|
|
651
|
-
this[LAYOUT] = layout;
|
|
652
|
-
},
|
|
653
|
-
writable: false,
|
|
654
|
-
configurable: false,
|
|
655
|
-
enumerable: false
|
|
656
|
-
}), "getLayout", {
|
|
657
|
-
value: function value() {
|
|
658
|
-
return this[LAYOUT];
|
|
659
|
-
},
|
|
660
|
-
writable: false,
|
|
661
|
-
configurable: false,
|
|
662
|
-
enumerable: false
|
|
663
|
-
}), "clone", {
|
|
664
|
-
value: function value(exclude_blocks) {
|
|
665
|
-
var filter = [LAYOUT, EXTEND, BUFFER];
|
|
666
|
-
if (exclude_blocks === true) {
|
|
667
|
-
filter.push(BLOCKS);
|
|
668
|
-
}
|
|
669
|
-
return omit(this, filter);
|
|
670
|
-
},
|
|
671
|
-
writable: false,
|
|
672
|
-
configurable: false,
|
|
673
|
-
enumerable: false
|
|
674
|
-
}), "extend", {
|
|
675
|
-
value: function value(layout) {
|
|
676
|
-
this.setExtend(true);
|
|
677
|
-
this.setLayout(layout);
|
|
678
|
-
},
|
|
679
|
-
writable: false,
|
|
680
|
-
configurable: false,
|
|
681
|
-
enumerable: false
|
|
682
|
-
}), "echo", {
|
|
683
|
-
value: function value(layout) {
|
|
684
|
-
var buffer = this.getBuffer();
|
|
685
|
-
var params = [].slice.call(arguments);
|
|
686
|
-
params.forEach(buffer);
|
|
687
|
-
},
|
|
688
|
-
writable: false,
|
|
689
|
-
configurable: false,
|
|
690
|
-
enumerable: false
|
|
691
|
-
}), "fn", {
|
|
692
|
-
value: function value(callback) {
|
|
693
|
-
var buffer = this.getBuffer();
|
|
694
|
-
var context = this;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}), "useElement", {
|
|
759
|
+
get: function get() {
|
|
760
|
+
if (isFunction(this[ELEMENT])) {
|
|
761
|
+
return this[ELEMENT].bind(this);
|
|
762
|
+
} else {
|
|
695
763
|
return function () {
|
|
764
|
+
throw new Error("".concat(ELEMENT, " must be a function"));
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}), "getMacro", {
|
|
769
|
+
value: function value() {
|
|
770
|
+
return this[MACRO];
|
|
771
|
+
}
|
|
772
|
+
}), "getBuffer", {
|
|
773
|
+
value: function value() {
|
|
774
|
+
return this[BUFFER];
|
|
775
|
+
}
|
|
776
|
+
}), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "getBlocks", {
|
|
777
|
+
value: function value() {
|
|
778
|
+
return this[BLOCKS];
|
|
779
|
+
}
|
|
780
|
+
}), "setExtend", {
|
|
781
|
+
value: function value(_value) {
|
|
782
|
+
this[EXTEND] = _value;
|
|
783
|
+
}
|
|
784
|
+
}), "getExtend", {
|
|
785
|
+
value: function value() {
|
|
786
|
+
return this[EXTEND];
|
|
787
|
+
}
|
|
788
|
+
}), "setLayout", {
|
|
789
|
+
value: function value(layout) {
|
|
790
|
+
this[LAYOUT] = layout;
|
|
791
|
+
}
|
|
792
|
+
}), "getLayout", {
|
|
793
|
+
value: function value() {
|
|
794
|
+
return this[LAYOUT];
|
|
795
|
+
}
|
|
796
|
+
}), "clone", {
|
|
797
|
+
value: function value(exclude_blocks) {
|
|
798
|
+
var filter = [LAYOUT, EXTEND, BUFFER];
|
|
799
|
+
if (exclude_blocks === true) {
|
|
800
|
+
filter.push(BLOCKS);
|
|
801
|
+
}
|
|
802
|
+
return omit(this, filter);
|
|
803
|
+
}
|
|
804
|
+
}), "extend", {
|
|
805
|
+
value: function value(layout) {
|
|
806
|
+
this.setExtend(true);
|
|
807
|
+
this.setLayout(layout);
|
|
808
|
+
}
|
|
809
|
+
}), "echo", {
|
|
810
|
+
value: function value(layout) {
|
|
811
|
+
var buffer = this.getBuffer();
|
|
812
|
+
var params = [].slice.call(arguments);
|
|
813
|
+
params.forEach(buffer);
|
|
814
|
+
}
|
|
815
|
+
}), "fn", {
|
|
816
|
+
value: function value(callback) {
|
|
817
|
+
var buffer = this.getBuffer();
|
|
818
|
+
var context = this;
|
|
819
|
+
return function () {
|
|
820
|
+
if (isFunction(callback)) {
|
|
696
821
|
buffer.backup();
|
|
697
|
-
|
|
698
|
-
callback.apply(context, arguments);
|
|
699
|
-
}
|
|
822
|
+
buffer(callback.apply(context, arguments));
|
|
700
823
|
return buffer.restore();
|
|
701
|
-
};
|
|
702
|
-
},
|
|
703
|
-
writable: false,
|
|
704
|
-
configurable: false,
|
|
705
|
-
enumerable: false
|
|
706
|
-
}), "get", {
|
|
707
|
-
value: function value(name, defaults) {
|
|
708
|
-
var path = getPath(this, name, true);
|
|
709
|
-
var result = path.shift();
|
|
710
|
-
var prop = path.pop();
|
|
711
|
-
return hasProp(result, prop) ? result[prop] : defaults;
|
|
712
|
-
},
|
|
713
|
-
writable: true,
|
|
714
|
-
configurable: true,
|
|
715
|
-
enumerable: false
|
|
716
|
-
}), "set", {
|
|
717
|
-
value: function value(name, _value2) {
|
|
718
|
-
var path = getPath(this, name, false);
|
|
719
|
-
var result = path.shift();
|
|
720
|
-
var prop = path.pop();
|
|
721
|
-
if (this.getExtend() && hasProp(result, prop)) {
|
|
722
|
-
return result[prop];
|
|
723
|
-
}
|
|
724
|
-
return result[prop] = _value2;
|
|
725
|
-
},
|
|
726
|
-
writable: false,
|
|
727
|
-
configurable: false,
|
|
728
|
-
enumerable: false
|
|
729
|
-
}), "macro", {
|
|
730
|
-
value: function value(name, callback) {
|
|
731
|
-
var list = this.getMacro();
|
|
732
|
-
var macro = this.fn(callback);
|
|
733
|
-
var context = this;
|
|
734
|
-
list[name] = function () {
|
|
735
|
-
return context.echo(macro.apply(undefined, arguments));
|
|
736
|
-
};
|
|
737
|
-
},
|
|
738
|
-
writable: false,
|
|
739
|
-
configurable: false,
|
|
740
|
-
enumerable: false
|
|
741
|
-
}), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "call", {
|
|
742
|
-
value: function value(name) {
|
|
743
|
-
var list = this.getMacro();
|
|
744
|
-
var macro = list[name];
|
|
745
|
-
var params = [].slice.call(arguments, 1);
|
|
746
|
-
if (isFunction(macro)) {
|
|
747
|
-
return macro.apply(macro, params);
|
|
748
824
|
}
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
var context = cx === false ? {} : this.clone(true);
|
|
789
|
-
var params = extend(context, data || {});
|
|
790
|
-
var promise = this.render(path, params);
|
|
791
|
-
this.echo(promise);
|
|
792
|
-
},
|
|
793
|
-
writable: false,
|
|
794
|
-
configurable: false,
|
|
795
|
-
enumerable: false
|
|
796
|
-
}), "promiseResolve", {
|
|
797
|
-
value: function value(_value3, callback) {
|
|
798
|
-
return Promise.resolve(isFunction(_value3) ? this.fn(_value3)() : _value3).then(callback.bind(this));
|
|
799
|
-
},
|
|
800
|
-
writable: false,
|
|
801
|
-
configurable: false,
|
|
802
|
-
enumerable: false
|
|
803
|
-
}), "use", {
|
|
804
|
-
value: function value(path, namespace) {
|
|
805
|
-
this.echo(this.promiseResolve(this.require(path), function (exports) {
|
|
806
|
-
var list = this.getMacro();
|
|
807
|
-
each(exports, function (macro, name) {
|
|
808
|
-
list[[namespace, name].join('.')] = macro;
|
|
809
|
-
});
|
|
810
|
-
}));
|
|
811
|
-
},
|
|
812
|
-
writable: false,
|
|
813
|
-
configurable: false,
|
|
814
|
-
enumerable: false
|
|
815
|
-
}), "async", {
|
|
816
|
-
value: function value(promise, callback) {
|
|
817
|
-
this.echo(this.promiseResolve(promise, function (data) {
|
|
818
|
-
return this.fn(callback)(data);
|
|
819
|
-
}));
|
|
820
|
-
},
|
|
821
|
-
writable: false,
|
|
822
|
-
configurable: false,
|
|
823
|
-
enumerable: false
|
|
824
|
-
}), "each", {
|
|
825
|
-
value: function value(object, callback) {
|
|
826
|
-
if (isString(object)) {
|
|
827
|
-
object = this.get(object, []);
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
}), "macro", {
|
|
828
|
+
value: function value(name, callback) {
|
|
829
|
+
var list = this.getMacro();
|
|
830
|
+
var macro = this.fn(callback);
|
|
831
|
+
var context = this;
|
|
832
|
+
list[name] = function () {
|
|
833
|
+
return context.echo(macro.apply(undefined, arguments));
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
}), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_Object$definePropert, "call", {
|
|
837
|
+
value: function value(name) {
|
|
838
|
+
var list = this.getMacro();
|
|
839
|
+
var macro = list[name];
|
|
840
|
+
var params = [].slice.call(arguments, 1);
|
|
841
|
+
if (isFunction(macro)) {
|
|
842
|
+
return macro.apply(macro, params);
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}), "block", {
|
|
846
|
+
value: function value(name, callback) {
|
|
847
|
+
var _this = this;
|
|
848
|
+
var blocks = this.getBlocks();
|
|
849
|
+
blocks[name] = blocks[name] || [];
|
|
850
|
+
blocks[name].push(this.fn(callback));
|
|
851
|
+
if (this.getExtend()) return;
|
|
852
|
+
var list = Object.assign([], blocks[name]);
|
|
853
|
+
var current = function current() {
|
|
854
|
+
return list.shift();
|
|
855
|
+
};
|
|
856
|
+
var _next = function next() {
|
|
857
|
+
var parent = current();
|
|
858
|
+
if (parent) {
|
|
859
|
+
return function () {
|
|
860
|
+
_this.echo(parent(_next()));
|
|
861
|
+
};
|
|
862
|
+
} else {
|
|
863
|
+
return noop;
|
|
828
864
|
}
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
865
|
+
};
|
|
866
|
+
this.echo(current()(_next()));
|
|
867
|
+
}
|
|
868
|
+
}), "hasBlock", {
|
|
869
|
+
value: function value(name) {
|
|
870
|
+
return this.getBlocks().hasOwnProperty(name);
|
|
871
|
+
}
|
|
872
|
+
}), "include", {
|
|
873
|
+
value: function value(path, data, cx) {
|
|
874
|
+
var context = cx === false ? {} : this.clone(true);
|
|
875
|
+
var params = extend(context, data || {});
|
|
876
|
+
var promise = this.render(path, params);
|
|
877
|
+
this.echo(promise);
|
|
878
|
+
}
|
|
879
|
+
}), "use", {
|
|
880
|
+
value: function value(path, namespace) {
|
|
881
|
+
var _this2 = this;
|
|
882
|
+
this.echo(Promise.resolve(this.require(path)).then(function (exports) {
|
|
883
|
+
var list = _this2.getMacro();
|
|
884
|
+
each(exports, function (macro, name) {
|
|
885
|
+
list[[namespace, name].join('.')] = macro;
|
|
886
|
+
});
|
|
887
|
+
}));
|
|
888
|
+
}
|
|
889
|
+
}), "async", {
|
|
890
|
+
value: function value(promise, callback) {
|
|
891
|
+
this.echo(Promise.resolve(promise).then(callback));
|
|
892
|
+
}
|
|
893
|
+
}), "get", {
|
|
894
|
+
value: function value(name, defaults) {
|
|
895
|
+
var path = getPath(this, name, true);
|
|
896
|
+
var result = path.shift();
|
|
897
|
+
var prop = path.pop();
|
|
898
|
+
return hasProp(result, prop) ? result[prop] : defaults;
|
|
899
|
+
}
|
|
900
|
+
}), "set", {
|
|
901
|
+
value: function value(name, _value2) {
|
|
902
|
+
var path = getPath(this, name, false);
|
|
903
|
+
var result = path.shift();
|
|
904
|
+
var prop = path.pop();
|
|
905
|
+
if (this.getExtend() && hasProp(result, prop)) {
|
|
906
|
+
return result[prop];
|
|
907
|
+
}
|
|
908
|
+
return result[prop] = _value2;
|
|
909
|
+
}
|
|
910
|
+
}), "each", {
|
|
911
|
+
value: function value(object, callback) {
|
|
912
|
+
if (isString(object)) {
|
|
913
|
+
object = this.get(object, []);
|
|
914
|
+
}
|
|
915
|
+
each(object, callback);
|
|
916
|
+
},
|
|
917
|
+
writable: true
|
|
918
|
+
}), "el", {
|
|
919
|
+
value: function value(tag, attr, content) {
|
|
920
|
+
content = isFunction(content) ? this.fn(content)() : content;
|
|
921
|
+
this.echo(Promise.resolve(content).then(function (content) {
|
|
836
922
|
return element(tag, attr, content);
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
923
|
+
}));
|
|
924
|
+
},
|
|
925
|
+
writable: true
|
|
926
|
+
}), _defineProperty(_Object$definePropert, "ui", {
|
|
927
|
+
value: function value(layout) {},
|
|
928
|
+
writable: true
|
|
929
|
+
})));
|
|
930
|
+
return ContextScope;
|
|
931
|
+
};
|
|
932
|
+
var _scope = /*#__PURE__*/new WeakMap();
|
|
933
|
+
var Context = /*#__PURE__*/function () {
|
|
934
|
+
function Context(config, methods) {
|
|
935
|
+
_classCallCheck(this, Context);
|
|
936
|
+
_classPrivateFieldInitSpec(this, _scope, void 0);
|
|
937
|
+
this.configure(config, methods);
|
|
938
|
+
}
|
|
939
|
+
return _createClass(Context, [{
|
|
940
|
+
key: "create",
|
|
941
|
+
value: function create(data) {
|
|
942
|
+
return new (_classPrivateFieldGet2(_scope, this))(data);
|
|
943
|
+
}
|
|
944
|
+
}, {
|
|
945
|
+
key: "configure",
|
|
946
|
+
value: function configure(config, methods) {
|
|
947
|
+
_classPrivateFieldSet2(_scope, this, createContextScope(config, methods));
|
|
948
|
+
}
|
|
949
|
+
}, {
|
|
950
|
+
key: "helpers",
|
|
951
|
+
value: function helpers(methods) {
|
|
952
|
+
extend(_classPrivateFieldGet2(_scope, this).prototype, methods || {});
|
|
953
|
+
}
|
|
954
|
+
}]);
|
|
955
|
+
}();
|
|
854
956
|
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
957
|
+
var _config = /*#__PURE__*/new WeakMap();
|
|
958
|
+
var _extend = /*#__PURE__*/new WeakMap();
|
|
959
|
+
var _context = /*#__PURE__*/new WeakMap();
|
|
960
|
+
var _compiler = /*#__PURE__*/new WeakMap();
|
|
961
|
+
var _cache = /*#__PURE__*/new WeakMap();
|
|
962
|
+
var _template = /*#__PURE__*/new WeakMap();
|
|
963
|
+
var _EJS_brand = /*#__PURE__*/new WeakSet();
|
|
964
|
+
var EJS = /*#__PURE__*/function () {
|
|
965
|
+
function EJS(options) {
|
|
966
|
+
_classCallCheck(this, EJS);
|
|
967
|
+
_classPrivateMethodInitSpec(this, _EJS_brand);
|
|
968
|
+
_classPrivateFieldInitSpec(this, _config, {});
|
|
969
|
+
_classPrivateFieldInitSpec(this, _extend, {});
|
|
970
|
+
_classPrivateFieldInitSpec(this, _context, void 0);
|
|
971
|
+
_classPrivateFieldInitSpec(this, _compiler, void 0);
|
|
972
|
+
_classPrivateFieldInitSpec(this, _cache, void 0);
|
|
973
|
+
_classPrivateFieldInitSpec(this, _template, void 0);
|
|
974
|
+
configSchema(_classPrivateFieldGet2(_config, this), options || {});
|
|
975
|
+
_classPrivateFieldSet2(_context, this, new Context(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_extend, this)));
|
|
976
|
+
_classPrivateFieldSet2(_compiler, this, new Compiler(_classPrivateFieldGet2(_config, this)));
|
|
977
|
+
_classPrivateFieldSet2(_cache, this, new Cache(_classPrivateFieldGet2(_config, this)));
|
|
978
|
+
_classPrivateFieldSet2(_template, this, new Template(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_cache, this), _classPrivateFieldGet2(_compiler, this)));
|
|
979
|
+
//
|
|
980
|
+
bindContext(this, ['configure', 'create', 'render', 'require', 'context', 'preload', 'compile', 'helpers']);
|
|
981
|
+
//
|
|
982
|
+
this.helpers({
|
|
983
|
+
require: this.require,
|
|
984
|
+
render: this.render
|
|
880
985
|
});
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
986
|
+
}
|
|
987
|
+
return _createClass(EJS, [{
|
|
988
|
+
key: "configure",
|
|
989
|
+
value: function configure(options) {
|
|
990
|
+
configSchema(_classPrivateFieldGet2(_config, this), options || {});
|
|
991
|
+
_classPrivateFieldGet2(_context, this).configure(_classPrivateFieldGet2(_config, this), _classPrivateFieldGet2(_extend, this));
|
|
992
|
+
_classPrivateFieldGet2(_compiler, this).configure(_classPrivateFieldGet2(_config, this));
|
|
993
|
+
_classPrivateFieldGet2(_cache, this).configure(_classPrivateFieldGet2(_config, this));
|
|
994
|
+
_classPrivateFieldGet2(_template, this).configure(_classPrivateFieldGet2(_config, this));
|
|
995
|
+
return _classPrivateFieldGet2(_config, this);
|
|
996
|
+
}
|
|
997
|
+
}, {
|
|
998
|
+
key: "render",
|
|
999
|
+
value: function render(name, data) {
|
|
1000
|
+
var _this = this;
|
|
1001
|
+
var filepath = ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1002
|
+
var scope = this.context(data);
|
|
1003
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, filepath, scope).then(function (content) {
|
|
1004
|
+
if (scope.getExtend()) {
|
|
1005
|
+
scope.setExtend(false);
|
|
1006
|
+
var layout = scope.getLayout();
|
|
1007
|
+
var _data = scope.clone();
|
|
1008
|
+
return _this.render(layout, _data);
|
|
1009
|
+
}
|
|
1010
|
+
return content;
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
}, {
|
|
1014
|
+
key: "helpers",
|
|
1015
|
+
value: function helpers(methods) {
|
|
1016
|
+
_classPrivateFieldGet2(_context, this).helpers(extend(_classPrivateFieldGet2(_extend, this), methods));
|
|
1017
|
+
}
|
|
1018
|
+
}, {
|
|
1019
|
+
key: "context",
|
|
1020
|
+
value: function context(data) {
|
|
1021
|
+
return _classPrivateFieldGet2(_context, this).create(data);
|
|
1022
|
+
}
|
|
1023
|
+
}, {
|
|
1024
|
+
key: "compile",
|
|
1025
|
+
value: function compile(content, path) {
|
|
1026
|
+
return _classPrivateFieldGet2(_compiler, this).compile(content, path);
|
|
1027
|
+
}
|
|
1028
|
+
}, {
|
|
1029
|
+
key: "preload",
|
|
1030
|
+
value: function preload(list) {
|
|
1031
|
+
return _classPrivateFieldGet2(_cache, this).load(list || {});
|
|
1032
|
+
}
|
|
1033
|
+
}, {
|
|
1034
|
+
key: "create",
|
|
1035
|
+
value: function create(options) {
|
|
1036
|
+
return new this.constructor(options);
|
|
1037
|
+
}
|
|
1038
|
+
}, {
|
|
1039
|
+
key: "require",
|
|
1040
|
+
value: function require(name) {
|
|
1041
|
+
var filepath = ext(name, _classPrivateFieldGet2(_config, this).extension);
|
|
1042
|
+
var scope = this.context({});
|
|
1043
|
+
return _assertClassBrand(_EJS_brand, this, _output).call(this, filepath, scope).then(function () {
|
|
1044
|
+
return scope.getMacro();
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
}]);
|
|
1048
|
+
}();
|
|
1049
|
+
function _output(path, scope) {
|
|
1050
|
+
var _classPrivateFieldGet2$1 = _classPrivateFieldGet2(_config, this),
|
|
1051
|
+
globalHelpers = _classPrivateFieldGet2$1.globalHelpers;
|
|
1052
|
+
var params = [scope, scope.getBuffer(), scope.useSafeValue, scope.useComponent, scope.useElement].concat(globalHelpers.filter(function (name) {
|
|
1053
|
+
return isFunction(scope[name]);
|
|
1054
|
+
}).map(function (name) {
|
|
1055
|
+
return scope[name].bind(scope);
|
|
1056
|
+
}));
|
|
1057
|
+
return _classPrivateFieldGet2(_template, this).get(path).then(function (callback) {
|
|
1058
|
+
return callback.apply(scope, params);
|
|
925
1059
|
});
|
|
926
|
-
return this;
|
|
927
1060
|
}
|
|
928
1061
|
|
|
929
1062
|
function readFile(path, template) {
|
|
@@ -940,10 +1073,11 @@ function readFile(path, template) {
|
|
|
940
1073
|
|
|
941
1074
|
/**
|
|
942
1075
|
*
|
|
943
|
-
* @param {
|
|
944
|
-
* @
|
|
1076
|
+
* @param {function(config: object):object} configure
|
|
1077
|
+
* @param {function(name: string, data?: object):Promise<string>} render
|
|
1078
|
+
* @return {function(name:any, options:any, callback: any): Promise<void>}
|
|
945
1079
|
*/
|
|
946
|
-
function expressRenderer(
|
|
1080
|
+
function expressRenderer(configure, render) {
|
|
947
1081
|
return function (name, options, callback) {
|
|
948
1082
|
if (isFunction(options)) {
|
|
949
1083
|
callback = options;
|
|
@@ -957,8 +1091,8 @@ function expressRenderer(ejs) {
|
|
|
957
1091
|
var filename = path.relative(viewPath, name);
|
|
958
1092
|
viewOptions.path = viewPath;
|
|
959
1093
|
viewOptions.cache = viewCache;
|
|
960
|
-
|
|
961
|
-
return
|
|
1094
|
+
configure(viewOptions);
|
|
1095
|
+
return render(filename, options).then(function (content) {
|
|
962
1096
|
callback(null, content);
|
|
963
1097
|
})["catch"](function (error) {
|
|
964
1098
|
callback(error);
|
|
@@ -966,17 +1100,17 @@ function expressRenderer(ejs) {
|
|
|
966
1100
|
};
|
|
967
1101
|
}
|
|
968
1102
|
|
|
969
|
-
var
|
|
970
|
-
|
|
971
|
-
})
|
|
972
|
-
|
|
973
|
-
context =
|
|
974
|
-
compile =
|
|
975
|
-
helpers =
|
|
976
|
-
preload =
|
|
977
|
-
configure =
|
|
978
|
-
create =
|
|
979
|
-
var __express = expressRenderer(
|
|
1103
|
+
var _EJS = new EJS({
|
|
1104
|
+
resolver: readFile
|
|
1105
|
+
}),
|
|
1106
|
+
render = _EJS.render,
|
|
1107
|
+
context = _EJS.context,
|
|
1108
|
+
compile = _EJS.compile,
|
|
1109
|
+
helpers = _EJS.helpers,
|
|
1110
|
+
preload = _EJS.preload,
|
|
1111
|
+
configure = _EJS.configure,
|
|
1112
|
+
create = _EJS.create;
|
|
1113
|
+
var __express = expressRenderer(configure, render);
|
|
980
1114
|
|
|
981
1115
|
exports.TemplateError = TemplateError;
|
|
982
1116
|
exports.TemplateNotFound = TemplateNotFound;
|