@kosatyi/ejs 0.0.49 → 0.0.51
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/element.js +4 -0
- package/dist/cjs/index.js +96 -101
- package/dist/esm/element.js +5 -1
- package/dist/esm/index.js +28 -42
- package/dist/umd/index.js +96 -99
- package/dist/umd/index.min.js +1 -1
- package/element.d.ts +6 -0
- package/global.d.ts +62 -15
- package/package.json +1 -4
package/dist/cjs/element.js
CHANGED
|
@@ -34,6 +34,9 @@ var entities = function entities() {
|
|
|
34
34
|
return htmlEntities[match];
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
|
+
var safeValue = function safeValue(value, escape, check) {
|
|
38
|
+
return (check = value) == null ? '' : escape ? entities(check) : check;
|
|
39
|
+
};
|
|
37
40
|
var each = function each(object, callback) {
|
|
38
41
|
var prop;
|
|
39
42
|
for (prop in object) {
|
|
@@ -82,3 +85,4 @@ var element = function element(tag, attrs, content) {
|
|
|
82
85
|
};
|
|
83
86
|
|
|
84
87
|
exports.element = element;
|
|
88
|
+
exports.safeValue = safeValue;
|
package/dist/cjs/index.js
CHANGED
|
@@ -4,13 +4,11 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var path = require('path');
|
|
6
6
|
var fs = require('fs');
|
|
7
|
-
var chokidar = require('chokidar');
|
|
8
7
|
|
|
9
8
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
10
9
|
|
|
11
10
|
var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
|
|
12
11
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
|
|
13
|
-
var chokidar__default = /*#__PURE__*/_interopDefaultLegacy(chokidar);
|
|
14
12
|
|
|
15
13
|
var defaults = {};
|
|
16
14
|
defaults["export"] = 'ejsPrecompiled';
|
|
@@ -36,6 +34,66 @@ defaults.token = {
|
|
|
36
34
|
regex: '([\\s\\S]+?)'
|
|
37
35
|
};
|
|
38
36
|
|
|
37
|
+
function _typeof(obj) {
|
|
38
|
+
"@babel/helpers - typeof";
|
|
39
|
+
|
|
40
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
41
|
+
return typeof obj;
|
|
42
|
+
} : function (obj) {
|
|
43
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
44
|
+
}, _typeof(obj);
|
|
45
|
+
}
|
|
46
|
+
function _classCallCheck(instance, Constructor) {
|
|
47
|
+
if (!(instance instanceof Constructor)) {
|
|
48
|
+
throw new TypeError("Cannot call a class as a function");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function _defineProperties(target, props) {
|
|
52
|
+
for (var i = 0; i < props.length; i++) {
|
|
53
|
+
var descriptor = props[i];
|
|
54
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
55
|
+
descriptor.configurable = true;
|
|
56
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
57
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
61
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
62
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
63
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
64
|
+
writable: false
|
|
65
|
+
});
|
|
66
|
+
return Constructor;
|
|
67
|
+
}
|
|
68
|
+
function _defineProperty(obj, key, value) {
|
|
69
|
+
key = _toPropertyKey(key);
|
|
70
|
+
if (key in obj) {
|
|
71
|
+
Object.defineProperty(obj, key, {
|
|
72
|
+
value: value,
|
|
73
|
+
enumerable: true,
|
|
74
|
+
configurable: true,
|
|
75
|
+
writable: true
|
|
76
|
+
});
|
|
77
|
+
} else {
|
|
78
|
+
obj[key] = value;
|
|
79
|
+
}
|
|
80
|
+
return obj;
|
|
81
|
+
}
|
|
82
|
+
function _toPrimitive(input, hint) {
|
|
83
|
+
if (typeof input !== "object" || input === null) return input;
|
|
84
|
+
var prim = input[Symbol.toPrimitive];
|
|
85
|
+
if (prim !== undefined) {
|
|
86
|
+
var res = prim.call(input, hint || "default");
|
|
87
|
+
if (typeof res !== "object") return res;
|
|
88
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
89
|
+
}
|
|
90
|
+
return (hint === "string" ? String : Number)(input);
|
|
91
|
+
}
|
|
92
|
+
function _toPropertyKey(arg) {
|
|
93
|
+
var key = _toPrimitive(arg, "string");
|
|
94
|
+
return typeof key === "symbol" ? key : String(key);
|
|
95
|
+
}
|
|
96
|
+
|
|
39
97
|
var typeProp = function typeProp() {
|
|
40
98
|
var args = [].slice.call(arguments);
|
|
41
99
|
var callback = args.shift();
|
|
@@ -50,6 +108,9 @@ var isString = function isString(v) {
|
|
|
50
108
|
var isBoolean = function isBoolean(v) {
|
|
51
109
|
return typeof v === 'boolean';
|
|
52
110
|
};
|
|
111
|
+
var isObject = function isObject(v) {
|
|
112
|
+
return _typeof(v) === 'object';
|
|
113
|
+
};
|
|
53
114
|
var isUndefined = function isUndefined(v) {
|
|
54
115
|
return typeof v === 'undefined';
|
|
55
116
|
};
|
|
@@ -193,57 +254,6 @@ var element = function element(tag, attrs, content) {
|
|
|
193
254
|
return result.join('');
|
|
194
255
|
};
|
|
195
256
|
|
|
196
|
-
function _classCallCheck(instance, Constructor) {
|
|
197
|
-
if (!(instance instanceof Constructor)) {
|
|
198
|
-
throw new TypeError("Cannot call a class as a function");
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
function _defineProperties(target, props) {
|
|
202
|
-
for (var i = 0; i < props.length; i++) {
|
|
203
|
-
var descriptor = props[i];
|
|
204
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
205
|
-
descriptor.configurable = true;
|
|
206
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
207
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
211
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
212
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
213
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
214
|
-
writable: false
|
|
215
|
-
});
|
|
216
|
-
return Constructor;
|
|
217
|
-
}
|
|
218
|
-
function _defineProperty(obj, key, value) {
|
|
219
|
-
key = _toPropertyKey(key);
|
|
220
|
-
if (key in obj) {
|
|
221
|
-
Object.defineProperty(obj, key, {
|
|
222
|
-
value: value,
|
|
223
|
-
enumerable: true,
|
|
224
|
-
configurable: true,
|
|
225
|
-
writable: true
|
|
226
|
-
});
|
|
227
|
-
} else {
|
|
228
|
-
obj[key] = value;
|
|
229
|
-
}
|
|
230
|
-
return obj;
|
|
231
|
-
}
|
|
232
|
-
function _toPrimitive(input, hint) {
|
|
233
|
-
if (typeof input !== "object" || input === null) return input;
|
|
234
|
-
var prim = input[Symbol.toPrimitive];
|
|
235
|
-
if (prim !== undefined) {
|
|
236
|
-
var res = prim.call(input, hint || "default");
|
|
237
|
-
if (typeof res !== "object") return res;
|
|
238
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
239
|
-
}
|
|
240
|
-
return (hint === "string" ? String : Number)(input);
|
|
241
|
-
}
|
|
242
|
-
function _toPropertyKey(arg) {
|
|
243
|
-
var key = _toPrimitive(arg, "string");
|
|
244
|
-
return typeof key === "symbol" ? key : String(key);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
257
|
var tagList = [{
|
|
248
258
|
symbol: '-',
|
|
249
259
|
format: function format(value) {
|
|
@@ -374,20 +384,6 @@ var fileSystem = function fileSystem(path, template) {
|
|
|
374
384
|
});
|
|
375
385
|
});
|
|
376
386
|
};
|
|
377
|
-
var disableWatcher = function disableWatcher(watcher) {
|
|
378
|
-
if (watcher) {
|
|
379
|
-
watcher.unwatch('.');
|
|
380
|
-
}
|
|
381
|
-
};
|
|
382
|
-
var enableWatcher = function enableWatcher(path, cache) {
|
|
383
|
-
return chokidar__default["default"].watch('.', {
|
|
384
|
-
cwd: path
|
|
385
|
-
}).on('change', function (name) {
|
|
386
|
-
cache.remove(name);
|
|
387
|
-
}).on('error', function (error) {
|
|
388
|
-
console.log('watcher error: ' + error);
|
|
389
|
-
});
|
|
390
|
-
};
|
|
391
387
|
var Template = /*#__PURE__*/function () {
|
|
392
388
|
function Template(config, cache, compiler) {
|
|
393
389
|
_classCallCheck(this, Template);
|
|
@@ -399,11 +395,21 @@ var Template = /*#__PURE__*/function () {
|
|
|
399
395
|
_createClass(Template, [{
|
|
400
396
|
key: "configure",
|
|
401
397
|
value: function configure(config) {
|
|
398
|
+
var _this = this;
|
|
402
399
|
this.path = config.path;
|
|
400
|
+
this.chokidar = config.chokidar;
|
|
403
401
|
this.resolver = isFunction(config.resolver) ? config.resolver : isNode() ? fileSystem : httpRequest;
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
402
|
+
if (config.watch && config.chokidar && isNode()) {
|
|
403
|
+
if (this.watcher) {
|
|
404
|
+
this.watcher.unwatch('.');
|
|
405
|
+
}
|
|
406
|
+
this.watcher = this.chokidar.watch('.', {
|
|
407
|
+
cwd: this.path
|
|
408
|
+
}).on('change', function (name) {
|
|
409
|
+
_this.cache.remove(name);
|
|
410
|
+
}).on('error', function (error) {
|
|
411
|
+
console.log('watcher error: ' + error);
|
|
412
|
+
});
|
|
407
413
|
}
|
|
408
414
|
}
|
|
409
415
|
}, {
|
|
@@ -429,12 +435,12 @@ var Template = /*#__PURE__*/function () {
|
|
|
429
435
|
}, {
|
|
430
436
|
key: "get",
|
|
431
437
|
value: function get(template) {
|
|
432
|
-
var
|
|
438
|
+
var _this2 = this;
|
|
433
439
|
if (this.cache.exist(template)) {
|
|
434
440
|
return this.cache.resolve(template);
|
|
435
441
|
}
|
|
436
442
|
var content = this.resolve(template).then(function (content) {
|
|
437
|
-
return
|
|
443
|
+
return _this2.result(template, _this2.compile(content, template));
|
|
438
444
|
});
|
|
439
445
|
return this.result(template, content);
|
|
440
446
|
}
|
|
@@ -743,15 +749,12 @@ var configSchema = function configSchema(config, options) {
|
|
|
743
749
|
withObject: typeProp(isBoolean, defaults.withObject, config.withObject, options.withObject),
|
|
744
750
|
rmWhitespace: typeProp(isBoolean, defaults.rmWhitespace, config.rmWhitespace, options.rmWhitespace),
|
|
745
751
|
watch: typeProp(isBoolean, defaults.watch, config.watch, options.watch),
|
|
752
|
+
chokidar: typeProp(isObject, defaults["export"], config["export"], options["export"]),
|
|
746
753
|
token: extend({}, defaults.token, config.token, options.token),
|
|
747
754
|
vars: extend({}, defaults.vars, config.vars, options.vars)
|
|
748
755
|
});
|
|
749
756
|
};
|
|
750
|
-
var
|
|
751
|
-
/**
|
|
752
|
-
* EJS template
|
|
753
|
-
* @module ejs
|
|
754
|
-
*/
|
|
757
|
+
var create = function create(options) {
|
|
755
758
|
var config = {};
|
|
756
759
|
var scope = {};
|
|
757
760
|
configSchema(config, options || {});
|
|
@@ -772,14 +775,14 @@ var init = function init(options) {
|
|
|
772
775
|
return callback.call(scope, scope, scope.getComponent(), scope.getBuffer(), safeValue);
|
|
773
776
|
});
|
|
774
777
|
};
|
|
775
|
-
var
|
|
778
|
+
var require = function require(name) {
|
|
776
779
|
var filepath = ext(name, config.extension);
|
|
777
780
|
var scope = context.create({});
|
|
778
781
|
return output(filepath, scope).then(function () {
|
|
779
782
|
return scope.getMacro();
|
|
780
783
|
});
|
|
781
784
|
};
|
|
782
|
-
var
|
|
785
|
+
var render = function render(name, data) {
|
|
783
786
|
var filepath = ext(name, config.extension);
|
|
784
787
|
var scope = context.create(data);
|
|
785
788
|
return output(filepath, scope).then(function (content) {
|
|
@@ -787,7 +790,7 @@ var init = function init(options) {
|
|
|
787
790
|
scope.setExtend(false);
|
|
788
791
|
var layout = scope.getLayout();
|
|
789
792
|
var _data = scope.clone();
|
|
790
|
-
return
|
|
793
|
+
return render(layout, _data);
|
|
791
794
|
}
|
|
792
795
|
return content;
|
|
793
796
|
});
|
|
@@ -809,7 +812,7 @@ var init = function init(options) {
|
|
|
809
812
|
viewOptions.path = viewPath;
|
|
810
813
|
viewOptions.cache = viewCache;
|
|
811
814
|
configure(viewOptions);
|
|
812
|
-
return
|
|
815
|
+
return render(filename, options).then(function (content) {
|
|
813
816
|
callback(null, content);
|
|
814
817
|
})["catch"](function (error) {
|
|
815
818
|
callback(error);
|
|
@@ -821,37 +824,29 @@ var init = function init(options) {
|
|
|
821
824
|
var compile = function compile(content, path) {
|
|
822
825
|
return compiler.compile(content, path);
|
|
823
826
|
};
|
|
824
|
-
var create = function create(options) {
|
|
825
|
-
return init(options);
|
|
826
|
-
};
|
|
827
827
|
helpers({
|
|
828
|
-
require:
|
|
829
|
-
|
|
830
|
-
},
|
|
831
|
-
render: function render(name, data) {
|
|
832
|
-
return _render(name, data);
|
|
833
|
-
}
|
|
828
|
+
require: require,
|
|
829
|
+
render: render
|
|
834
830
|
});
|
|
835
831
|
return {
|
|
836
|
-
|
|
832
|
+
context: context,
|
|
833
|
+
render: render,
|
|
837
834
|
helpers: helpers,
|
|
838
835
|
configure: configure,
|
|
839
836
|
compile: compile,
|
|
840
837
|
create: create,
|
|
841
838
|
preload: preload,
|
|
842
|
-
context: context,
|
|
843
839
|
__express: __express
|
|
844
840
|
};
|
|
845
841
|
};
|
|
846
|
-
var
|
|
847
|
-
context =
|
|
848
|
-
render =
|
|
849
|
-
helpers =
|
|
850
|
-
configure =
|
|
851
|
-
compile =
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
__express = _init.__express;
|
|
842
|
+
var _create = create({}),
|
|
843
|
+
context = _create.context,
|
|
844
|
+
render = _create.render,
|
|
845
|
+
helpers = _create.helpers,
|
|
846
|
+
configure = _create.configure,
|
|
847
|
+
compile = _create.compile,
|
|
848
|
+
preload = _create.preload,
|
|
849
|
+
__express = _create.__express;
|
|
855
850
|
|
|
856
851
|
exports.__express = __express;
|
|
857
852
|
exports.compile = compile;
|
package/dist/esm/element.js
CHANGED
|
@@ -36,6 +36,10 @@ const entities = (string = '') => {
|
|
|
36
36
|
)
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
+
const safeValue = (value, escape, check) => {
|
|
40
|
+
return (check = value) == null ? '' : escape ? entities(check) : check
|
|
41
|
+
};
|
|
42
|
+
|
|
39
43
|
const each = (object, callback) => {
|
|
40
44
|
let prop;
|
|
41
45
|
for (prop in object) {
|
|
@@ -107,4 +111,4 @@ const element = (tag, attrs, content) => {
|
|
|
107
111
|
return result.join('')
|
|
108
112
|
};
|
|
109
113
|
|
|
110
|
-
export { element };
|
|
114
|
+
export { element, safeValue };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import fs from 'fs';
|
|
3
|
-
import chokidar from 'chokidar';
|
|
4
3
|
|
|
5
4
|
const defaults = {};
|
|
6
5
|
|
|
@@ -43,6 +42,7 @@ const typeProp = function () {
|
|
|
43
42
|
const isFunction = (v) => typeof v === 'function';
|
|
44
43
|
const isString = (v) => typeof v === 'string';
|
|
45
44
|
const isBoolean = (v) => typeof v === 'boolean';
|
|
45
|
+
const isObject = (v) => typeof v === 'object';
|
|
46
46
|
const isUndefined = (v) => typeof v === 'undefined';
|
|
47
47
|
|
|
48
48
|
const isNodeEnv =
|
|
@@ -367,25 +367,6 @@ const fileSystem = (path, template) => {
|
|
|
367
367
|
})
|
|
368
368
|
};
|
|
369
369
|
|
|
370
|
-
const disableWatcher = (watcher) => {
|
|
371
|
-
if (watcher) {
|
|
372
|
-
watcher.unwatch('.');
|
|
373
|
-
}
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
const enableWatcher = (path, cache) => {
|
|
377
|
-
return chokidar
|
|
378
|
-
.watch('.', {
|
|
379
|
-
cwd: path,
|
|
380
|
-
})
|
|
381
|
-
.on('change', (name) => {
|
|
382
|
-
cache.remove(name);
|
|
383
|
-
})
|
|
384
|
-
.on('error', (error) => {
|
|
385
|
-
console.log('watcher error: ' + error);
|
|
386
|
-
})
|
|
387
|
-
};
|
|
388
|
-
|
|
389
370
|
class Template {
|
|
390
371
|
constructor(config, cache, compiler) {
|
|
391
372
|
this.cache = cache;
|
|
@@ -395,14 +376,24 @@ class Template {
|
|
|
395
376
|
}
|
|
396
377
|
configure(config) {
|
|
397
378
|
this.path = config.path;
|
|
379
|
+
this.chokidar = config.chokidar;
|
|
398
380
|
this.resolver = isFunction(config.resolver)
|
|
399
381
|
? config.resolver
|
|
400
382
|
: isNode()
|
|
401
383
|
? fileSystem
|
|
402
384
|
: httpRequest;
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
385
|
+
if (config.watch && config.chokidar && isNode()) {
|
|
386
|
+
if (this.watcher) {
|
|
387
|
+
this.watcher.unwatch('.');
|
|
388
|
+
}
|
|
389
|
+
this.watcher = this.chokidar
|
|
390
|
+
.watch('.', { cwd: this.path })
|
|
391
|
+
.on('change', (name) => {
|
|
392
|
+
this.cache.remove(name);
|
|
393
|
+
})
|
|
394
|
+
.on('error', (error) => {
|
|
395
|
+
console.log('watcher error: ' + error);
|
|
396
|
+
});
|
|
406
397
|
}
|
|
407
398
|
}
|
|
408
399
|
resolve(template) {
|
|
@@ -778,16 +769,18 @@ const configSchema = (config, options) => {
|
|
|
778
769
|
options.rmWhitespace
|
|
779
770
|
),
|
|
780
771
|
watch: typeProp(isBoolean, defaults.watch, config.watch, options.watch),
|
|
772
|
+
chokidar: typeProp(
|
|
773
|
+
isObject,
|
|
774
|
+
defaults.export,
|
|
775
|
+
config.export,
|
|
776
|
+
options.export
|
|
777
|
+
),
|
|
781
778
|
token: extend({}, defaults.token, config.token, options.token),
|
|
782
779
|
vars: extend({}, defaults.vars, config.vars, options.vars),
|
|
783
780
|
});
|
|
784
781
|
};
|
|
785
782
|
|
|
786
|
-
const
|
|
787
|
-
/**
|
|
788
|
-
* EJS template
|
|
789
|
-
* @module ejs
|
|
790
|
-
*/
|
|
783
|
+
const create = (options) => {
|
|
791
784
|
const config = {};
|
|
792
785
|
const scope = {};
|
|
793
786
|
|
|
@@ -871,27 +864,21 @@ const init = (options) => {
|
|
|
871
864
|
callback(error);
|
|
872
865
|
})
|
|
873
866
|
};
|
|
867
|
+
|
|
874
868
|
const preload = (list) => cache.load(list);
|
|
869
|
+
|
|
875
870
|
const compile = (content, path) => compiler.compile(content, path);
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
helpers({
|
|
880
|
-
require(name) {
|
|
881
|
-
return require(name)
|
|
882
|
-
},
|
|
883
|
-
render(name, data) {
|
|
884
|
-
return render(name, data)
|
|
885
|
-
},
|
|
886
|
-
});
|
|
871
|
+
|
|
872
|
+
helpers({ require, render });
|
|
873
|
+
|
|
887
874
|
return {
|
|
875
|
+
context,
|
|
888
876
|
render,
|
|
889
877
|
helpers,
|
|
890
878
|
configure,
|
|
891
879
|
compile,
|
|
892
880
|
create,
|
|
893
881
|
preload,
|
|
894
|
-
context,
|
|
895
882
|
__express,
|
|
896
883
|
}
|
|
897
884
|
};
|
|
@@ -902,9 +889,8 @@ const {
|
|
|
902
889
|
helpers,
|
|
903
890
|
configure,
|
|
904
891
|
compile,
|
|
905
|
-
create,
|
|
906
892
|
preload,
|
|
907
893
|
__express,
|
|
908
|
-
} =
|
|
894
|
+
} = create({});
|
|
909
895
|
|
|
910
896
|
export { __express, compile, configure, context, create, element, helpers, preload, render, safeValue };
|
package/dist/umd/index.js
CHANGED
|
@@ -30,6 +30,66 @@
|
|
|
30
30
|
regex: '([\\s\\S]+?)'
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
+
function _typeof(obj) {
|
|
34
|
+
"@babel/helpers - typeof";
|
|
35
|
+
|
|
36
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
|
|
37
|
+
return typeof obj;
|
|
38
|
+
} : function (obj) {
|
|
39
|
+
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
40
|
+
}, _typeof(obj);
|
|
41
|
+
}
|
|
42
|
+
function _classCallCheck(instance, Constructor) {
|
|
43
|
+
if (!(instance instanceof Constructor)) {
|
|
44
|
+
throw new TypeError("Cannot call a class as a function");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function _defineProperties(target, props) {
|
|
48
|
+
for (var i = 0; i < props.length; i++) {
|
|
49
|
+
var descriptor = props[i];
|
|
50
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
51
|
+
descriptor.configurable = true;
|
|
52
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
53
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
57
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
58
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
59
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
60
|
+
writable: false
|
|
61
|
+
});
|
|
62
|
+
return Constructor;
|
|
63
|
+
}
|
|
64
|
+
function _defineProperty(obj, key, value) {
|
|
65
|
+
key = _toPropertyKey(key);
|
|
66
|
+
if (key in obj) {
|
|
67
|
+
Object.defineProperty(obj, key, {
|
|
68
|
+
value: value,
|
|
69
|
+
enumerable: true,
|
|
70
|
+
configurable: true,
|
|
71
|
+
writable: true
|
|
72
|
+
});
|
|
73
|
+
} else {
|
|
74
|
+
obj[key] = value;
|
|
75
|
+
}
|
|
76
|
+
return obj;
|
|
77
|
+
}
|
|
78
|
+
function _toPrimitive(input, hint) {
|
|
79
|
+
if (typeof input !== "object" || input === null) return input;
|
|
80
|
+
var prim = input[Symbol.toPrimitive];
|
|
81
|
+
if (prim !== undefined) {
|
|
82
|
+
var res = prim.call(input, hint || "default");
|
|
83
|
+
if (typeof res !== "object") return res;
|
|
84
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
85
|
+
}
|
|
86
|
+
return (hint === "string" ? String : Number)(input);
|
|
87
|
+
}
|
|
88
|
+
function _toPropertyKey(arg) {
|
|
89
|
+
var key = _toPrimitive(arg, "string");
|
|
90
|
+
return typeof key === "symbol" ? key : String(key);
|
|
91
|
+
}
|
|
92
|
+
|
|
33
93
|
var typeProp = function typeProp() {
|
|
34
94
|
var args = [].slice.call(arguments);
|
|
35
95
|
var callback = args.shift();
|
|
@@ -44,6 +104,9 @@
|
|
|
44
104
|
var isBoolean = function isBoolean(v) {
|
|
45
105
|
return typeof v === 'boolean';
|
|
46
106
|
};
|
|
107
|
+
var isObject = function isObject(v) {
|
|
108
|
+
return _typeof(v) === 'object';
|
|
109
|
+
};
|
|
47
110
|
var isUndefined = function isUndefined(v) {
|
|
48
111
|
return typeof v === 'undefined';
|
|
49
112
|
};
|
|
@@ -187,57 +250,6 @@
|
|
|
187
250
|
return result.join('');
|
|
188
251
|
};
|
|
189
252
|
|
|
190
|
-
function _classCallCheck(instance, Constructor) {
|
|
191
|
-
if (!(instance instanceof Constructor)) {
|
|
192
|
-
throw new TypeError("Cannot call a class as a function");
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
function _defineProperties(target, props) {
|
|
196
|
-
for (var i = 0; i < props.length; i++) {
|
|
197
|
-
var descriptor = props[i];
|
|
198
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
199
|
-
descriptor.configurable = true;
|
|
200
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
201
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
205
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
206
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
207
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
208
|
-
writable: false
|
|
209
|
-
});
|
|
210
|
-
return Constructor;
|
|
211
|
-
}
|
|
212
|
-
function _defineProperty(obj, key, value) {
|
|
213
|
-
key = _toPropertyKey(key);
|
|
214
|
-
if (key in obj) {
|
|
215
|
-
Object.defineProperty(obj, key, {
|
|
216
|
-
value: value,
|
|
217
|
-
enumerable: true,
|
|
218
|
-
configurable: true,
|
|
219
|
-
writable: true
|
|
220
|
-
});
|
|
221
|
-
} else {
|
|
222
|
-
obj[key] = value;
|
|
223
|
-
}
|
|
224
|
-
return obj;
|
|
225
|
-
}
|
|
226
|
-
function _toPrimitive(input, hint) {
|
|
227
|
-
if (typeof input !== "object" || input === null) return input;
|
|
228
|
-
var prim = input[Symbol.toPrimitive];
|
|
229
|
-
if (prim !== undefined) {
|
|
230
|
-
var res = prim.call(input, hint || "default");
|
|
231
|
-
if (typeof res !== "object") return res;
|
|
232
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
233
|
-
}
|
|
234
|
-
return (hint === "string" ? String : Number)(input);
|
|
235
|
-
}
|
|
236
|
-
function _toPropertyKey(arg) {
|
|
237
|
-
var key = _toPrimitive(arg, "string");
|
|
238
|
-
return typeof key === "symbol" ? key : String(key);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
253
|
var tagList = [{
|
|
242
254
|
symbol: '-',
|
|
243
255
|
format: function format(value) {
|
|
@@ -368,20 +380,6 @@
|
|
|
368
380
|
});
|
|
369
381
|
});
|
|
370
382
|
};
|
|
371
|
-
var disableWatcher = function disableWatcher(watcher) {
|
|
372
|
-
if (watcher) {
|
|
373
|
-
watcher.unwatch('.');
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
var enableWatcher = function enableWatcher(path$1, cache) {
|
|
377
|
-
return path.watch('.', {
|
|
378
|
-
cwd: path$1
|
|
379
|
-
}).on('change', function (name) {
|
|
380
|
-
cache.remove(name);
|
|
381
|
-
}).on('error', function (error) {
|
|
382
|
-
console.log('watcher error: ' + error);
|
|
383
|
-
});
|
|
384
|
-
};
|
|
385
383
|
var Template = /*#__PURE__*/function () {
|
|
386
384
|
function Template(config, cache, compiler) {
|
|
387
385
|
_classCallCheck(this, Template);
|
|
@@ -393,11 +391,21 @@
|
|
|
393
391
|
_createClass(Template, [{
|
|
394
392
|
key: "configure",
|
|
395
393
|
value: function configure(config) {
|
|
394
|
+
var _this = this;
|
|
396
395
|
this.path = config.path;
|
|
396
|
+
this.chokidar = config.chokidar;
|
|
397
397
|
this.resolver = isFunction(config.resolver) ? config.resolver : isNode() ? fileSystem : httpRequest;
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
398
|
+
if (config.watch && config.chokidar && isNode()) {
|
|
399
|
+
if (this.watcher) {
|
|
400
|
+
this.watcher.unwatch('.');
|
|
401
|
+
}
|
|
402
|
+
this.watcher = this.chokidar.watch('.', {
|
|
403
|
+
cwd: this.path
|
|
404
|
+
}).on('change', function (name) {
|
|
405
|
+
_this.cache.remove(name);
|
|
406
|
+
}).on('error', function (error) {
|
|
407
|
+
console.log('watcher error: ' + error);
|
|
408
|
+
});
|
|
401
409
|
}
|
|
402
410
|
}
|
|
403
411
|
}, {
|
|
@@ -423,12 +431,12 @@
|
|
|
423
431
|
}, {
|
|
424
432
|
key: "get",
|
|
425
433
|
value: function get(template) {
|
|
426
|
-
var
|
|
434
|
+
var _this2 = this;
|
|
427
435
|
if (this.cache.exist(template)) {
|
|
428
436
|
return this.cache.resolve(template);
|
|
429
437
|
}
|
|
430
438
|
var content = this.resolve(template).then(function (content) {
|
|
431
|
-
return
|
|
439
|
+
return _this2.result(template, _this2.compile(content, template));
|
|
432
440
|
});
|
|
433
441
|
return this.result(template, content);
|
|
434
442
|
}
|
|
@@ -737,15 +745,12 @@
|
|
|
737
745
|
withObject: typeProp(isBoolean, defaults.withObject, config.withObject, options.withObject),
|
|
738
746
|
rmWhitespace: typeProp(isBoolean, defaults.rmWhitespace, config.rmWhitespace, options.rmWhitespace),
|
|
739
747
|
watch: typeProp(isBoolean, defaults.watch, config.watch, options.watch),
|
|
748
|
+
chokidar: typeProp(isObject, defaults["export"], config["export"], options["export"]),
|
|
740
749
|
token: extend({}, defaults.token, config.token, options.token),
|
|
741
750
|
vars: extend({}, defaults.vars, config.vars, options.vars)
|
|
742
751
|
});
|
|
743
752
|
};
|
|
744
|
-
var
|
|
745
|
-
/**
|
|
746
|
-
* EJS template
|
|
747
|
-
* @module ejs
|
|
748
|
-
*/
|
|
753
|
+
var create = function create(options) {
|
|
749
754
|
var config = {};
|
|
750
755
|
var scope = {};
|
|
751
756
|
configSchema(config, options || {});
|
|
@@ -766,14 +771,14 @@
|
|
|
766
771
|
return callback.call(scope, scope, scope.getComponent(), scope.getBuffer(), safeValue);
|
|
767
772
|
});
|
|
768
773
|
};
|
|
769
|
-
var
|
|
774
|
+
var require = function require(name) {
|
|
770
775
|
var filepath = ext(name, config.extension);
|
|
771
776
|
var scope = context.create({});
|
|
772
777
|
return output(filepath, scope).then(function () {
|
|
773
778
|
return scope.getMacro();
|
|
774
779
|
});
|
|
775
780
|
};
|
|
776
|
-
var
|
|
781
|
+
var render = function render(name, data) {
|
|
777
782
|
var filepath = ext(name, config.extension);
|
|
778
783
|
var scope = context.create(data);
|
|
779
784
|
return output(filepath, scope).then(function (content) {
|
|
@@ -781,7 +786,7 @@
|
|
|
781
786
|
scope.setExtend(false);
|
|
782
787
|
var layout = scope.getLayout();
|
|
783
788
|
var _data = scope.clone();
|
|
784
|
-
return
|
|
789
|
+
return render(layout, _data);
|
|
785
790
|
}
|
|
786
791
|
return content;
|
|
787
792
|
});
|
|
@@ -803,7 +808,7 @@
|
|
|
803
808
|
viewOptions.path = viewPath;
|
|
804
809
|
viewOptions.cache = viewCache;
|
|
805
810
|
configure(viewOptions);
|
|
806
|
-
return
|
|
811
|
+
return render(filename, options).then(function (content) {
|
|
807
812
|
callback(null, content);
|
|
808
813
|
})["catch"](function (error) {
|
|
809
814
|
callback(error);
|
|
@@ -815,37 +820,29 @@
|
|
|
815
820
|
var compile = function compile(content, path) {
|
|
816
821
|
return compiler.compile(content, path);
|
|
817
822
|
};
|
|
818
|
-
var create = function create(options) {
|
|
819
|
-
return init(options);
|
|
820
|
-
};
|
|
821
823
|
helpers({
|
|
822
|
-
require:
|
|
823
|
-
|
|
824
|
-
},
|
|
825
|
-
render: function render(name, data) {
|
|
826
|
-
return _render(name, data);
|
|
827
|
-
}
|
|
824
|
+
require: require,
|
|
825
|
+
render: render
|
|
828
826
|
});
|
|
829
827
|
return {
|
|
830
|
-
|
|
828
|
+
context: context,
|
|
829
|
+
render: render,
|
|
831
830
|
helpers: helpers,
|
|
832
831
|
configure: configure,
|
|
833
832
|
compile: compile,
|
|
834
833
|
create: create,
|
|
835
834
|
preload: preload,
|
|
836
|
-
context: context,
|
|
837
835
|
__express: __express
|
|
838
836
|
};
|
|
839
837
|
};
|
|
840
|
-
var
|
|
841
|
-
context =
|
|
842
|
-
render =
|
|
843
|
-
helpers =
|
|
844
|
-
configure =
|
|
845
|
-
compile =
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
__express = _init.__express;
|
|
838
|
+
var _create = create({}),
|
|
839
|
+
context = _create.context,
|
|
840
|
+
render = _create.render,
|
|
841
|
+
helpers = _create.helpers,
|
|
842
|
+
configure = _create.configure,
|
|
843
|
+
compile = _create.compile,
|
|
844
|
+
preload = _create.preload,
|
|
845
|
+
__express = _create.__express;
|
|
849
846
|
|
|
850
847
|
exports.__express = __express;
|
|
851
848
|
exports.compile = compile;
|
package/dist/umd/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ejs={})}(this,(function(t){"use strict";var e={},n={export:"ejsPrecompiled",watch:!1,path:"views",resolver:null,extension:"ejs",rmWhitespace:!0,withObject:!0,vars:{SCOPE:"ejs",COMPONENT:"ui",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},token:{start:"<%",end:"%>",regex:"([\\s\\S]+?)"}},r=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},i=function(t){return"function"==typeof t},o=function(t){return"string"==typeof t},c=function(t){return"boolean"==typeof t},u=function(t){return void 0===t},s="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),a=function(){return s},h={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},f={"&":"&","<":"<",">":">",'"':""","'":"'"},l=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},p=l(f),v=l(h),d=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(""+t).replace(p,(function(t){return f[t]}))},m=function(t,e,n){return null==(n=t)?"":e?d(n):n},g=function(t,e){var n=t,r=e.split("."),i=r.pop();return r.forEach((function(t){n=n[t]=n[t]||{}})),[n,i]},y=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},b=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=e.shift();return e.filter((function(t){return t})).reduce((function(t,e){return Object.assign(t,e)}),r)},w=function(){},x=function(t,e){var n;for(n in t)E(t,n)&&e(t[n],n,t)},j=function(t,e){return function(t,e,n){var r=t instanceof Array,i=r?[]:{};return x(t,(function(t,n,o){var c=e(t,n,o);!1===u(c)&&(r?i.push(c):i[n]=c)})),i}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},k=function(t,e,n){return Promise.resolve(t).then(e.bind(n))},E=function(t,e){return t&&t.hasOwnProperty(e)},O=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],F=" ",B='"',P="/",R="<",S=">",$=function(t,e,n){var r=[],i=-1===O.indexOf(t),o=function(t,e,n){var r=[];return x(t,(function(t,n,i){var o=e(t,n,i);!1===u(o)&&r.push(o)})),r}(e,(function(t,e){if(null!=t)return[d(e),[B,d(t),B].join("")].join("=")})).join(F);return r.push([R,t,F,o,S].join("")),n&&r.push(n instanceof Array?n.join(""):n),i&&r.push([R,P,t,S].join("")),r.join("")};function M(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function T(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,U(r.key),r)}}function C(t,e,n){return e&&T(t.prototype,e),n&&T(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function U(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}var A=[{symbol:"-",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(t){return"')\n/**".concat(t,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(t){return"')\n".concat(t.trim(),"\n").concat(this.BUFFER,"('")}}],_=function(){function t(e){M(this,t),this.configure(e)}return C(t,[{key:"configure",value:function(t){var e=this;this.withObject=t.withObject,this.rmWhitespace=t.rmWhitespace,this.token=t.token,this.vars=t.vars,this.matches=[],this.formats=[],this.slurp={match:"[ \\t]*",start:[this.token.start,"_"],end:["_",this.token.end]},A.forEach((function(t){e.matches.push(e.token.start.concat(t.symbol).concat(e.token.regex).concat(e.token.end)),e.formats.push(t.format.bind(e.vars))})),this.regex=new RegExp(this.matches.join("|").concat("|$"),"g"),this.slurpStart=new RegExp([this.slurp.match,this.slurp.start.join("")].join(""),"gm"),this.slurpEnd=new RegExp([this.slurp.end.join(""),this.slurp.match].join(""),"gm")}},{key:"truncate",value:function(t){return t&&t.replace(/^(?:\r\n|\r|\n)/,"")}},{key:"compile",value:function(t,e){var n=this,r=this.vars,i=r.SCOPE,o=r.SAFE,c=r.BUFFER,u=r.COMPONENT;this.rmWhitespace&&(t=t.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=t.replace(this.slurpStart,this.token.start).replace(this.slurpEnd,this.token.end);var s,a,f,l="".concat(c,"('");s=this.regex,a=function(e,r,i){l+=(""+t.slice(r,i)).replace(v,(function(t){return"\\"+h[t]})),e.forEach((function(t,e){t&&(l+=n.formats[e](t))}))},f=0,t.replace(s,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return a(t,f,e),f=e+n.length,n})),l="try{".concat(l+="');","}catch(e){console.info(e)}"),this.withObject&&(l="with(".concat(i,"){").concat(l,"}")),l="".concat(c,".start();").concat(l,"return ").concat(c,".end();"),l+="\n//# sourceURL=".concat(e);var p=null;try{(p=new Function(i,u,c,o,l)).source="(function(".concat(i,",").concat(u,",").concat(c,",").concat(o,"){\n").concat(l,"\n})")}catch(t){throw t.filename=e,t.source=l,t}return p}}]),t}(),L=function(t,e){return e=(e=[t,e].join("/")).replace(/\/\//g,"/")},N=function(t,e){return fetch(L(t,e)).then((function(t){return t.text()}))},W=function(t,n){return new Promise((function(r,i){e.readFile(L(t,n),(function(t,e){t?i(t):r(e.toString())}))}))},q=function(){function t(e,n,r){M(this,t),this.cache=n,this.watcher=null,this.compiler=r,this.configure(e)}return C(t,[{key:"configure",value:function(t){var n,r,o;this.path=t.path,this.resolver=i(t.resolver)?t.resolver:a()?W:N,(n=this.watcher)&&n.unwatch("."),t.watch&&a()&&(this.watcher=(r=this.path,o=this.cache,e.watch(".",{cwd:r}).on("change",(function(t){o.remove(t)})).on("error",(function(t){console.log("watcher error: "+t)}))))}},{key:"resolve",value:function(t){return this.resolver(this.path,t)}},{key:"result",value:function(t,e){return this.cache.set(t,e),e}},{key:"compile",value:function(t,e){return i(t)?t:this.compiler.compile(t,e)}},{key:"get",value:function(t){var e=this;if(this.cache.exist(t))return this.cache.resolve(t);var n=this.resolve(t).then((function(n){return e.result(t,e.compile(n,t))}));return this.result(t,n)}}]),t}(),D=function(t){return Promise.all(t).then((function(t){return t.join("")}))},K=function(){function t(e){M(this,t),this.configure(e)}return C(t,[{key:"configure",value:function(t,e){var n=t.vars,r=n.EXTEND,c=n.LAYOUT,u=n.BLOCKS,s=n.BUFFER,a=n.MACRO,h=n.COMPONENT;function f(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),b(this,t)}this.create=function(t){return new f(t)},this.helpers=function(t){b(f.prototype,t)},f.prototype=b({},e||{}),f.define=f.method=function(t,e,n,r,i){return Object.defineProperty(f.prototype,t,{value:e,writable:n||!1,configurable:r||!1,enumerable:i||!1})},f.define(s,function(){var t=[],e=[];function n(t){e.push(t)}return n.start=function(){e=[]},n.backup=function(){t.push(e.concat()),e=[]},n.restore=function(){var n=e.concat();return e=t.pop(),D(n)},n.error=function(t){throw t},n.end=function(){return D(e)},n}()),f.define(u,{},!0),f.define(a,{},!0),f.define(c,!1,!0),f.define(r,!1,!0),f.method("initBlocks",(function(){this[u]={}})),f.method("initMacro",(function(){this[a]={}})),f.method("getMacro",(function(){return this[a]})),f.method("getBuffer",(function(){return this[s]})),f.method("getComponent",(function(){var t=this;return h in t?function(){return t[h].apply(t,arguments)}:function(){console.log("%s function not defined",h)}})),f.method("getBlocks",(function(){return this[u]})),f.method("setExtend",(function(t){this[r]=t})),f.method("getExtend",(function(){return this[r]})),f.method("setLayout",(function(t){this[c]=t})),f.method("getLayout",(function(){return this[c]})),f.method("clone",(function(t){var e=[c,r,s];return!0===t&&e.push(u),j(this,e)})),f.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),f.method("echo",(function(){var t=this.getBuffer(),e=[].slice.call(arguments);e.forEach(t)})),f.method("fn",(function(t){var e=this.getBuffer(),n=this;return function(){return e.backup(),i(t)&&t.apply(n,arguments),e.restore()}})),f.method("get",(function(t,e){var n=g(this,t),r=n.shift(),i=n.pop();return E(r,i)?r[i]:e})),f.method("set",(function(t,e){var n=g(this,t),r=n.shift(),i=n.pop();return this.getExtend()&&E(r,i)?r[i]:r[i]=e})),f.method("macro",(function(t,e){var n=this.getMacro(),r=this.fn(e),i=this;n[t]=function(){return i.echo(r.apply(void 0,arguments))}})),f.method("call",(function(t){var e=this.getMacro(),n=e[t],r=[].slice.call(arguments,1);if(i(n))return n.apply(n,r)})),f.method("block",(function(t,e){var n=this,r=this.getBlocks();if(r[t]=r[t]||[],r[t].push(this.fn(e)),!this.getExtend()){var i=Object.assign([],r[t]),o=function(){return i.shift()};this.echo(o()(function t(){var e=o();return e?function(){n.echo(e(t()))}:w}()))}})),f.method("include",(function(t,e,n){var r=!1===n?{}:this.clone(!0),i=b(r,e||{}),o=this.render(t,i);this.echo(o)})),f.method("use",(function(t,e){var n=this.require(t);this.echo(k(n,(function(t){var n=this.getMacro();x(t,(function(t,r){n[[e,r].join(".")]=t}))}),this))})),f.method("async",(function(t,e){this.echo(k(t,(function(t){return this.fn(e)(t)}),this))})),f.method("node",(function(t,e,n){return $(t,e,n)})),f.method("el",(function(t,e,n){i(n)&&(n=this.fn(n)()),this.echo(k(n,(function(n){return $(t,e,n)}),this))})),f.method("each",(function(t,e){o(t)&&(t=this.get(t,[])),x(t,e)}))}}]),t}(),X="undefined"!=typeof globalThis?globalThis:window||self,Y=function(){function t(e){var n,r,i;M(this,t),n=this,i={},(r=U(r="list"))in n?Object.defineProperty(n,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[r]=i,this.configure(e),!1===a()&&this.load(X[this.namespace])}return C(t,[{key:"configure",value:function(t){this.list={},this.namespace=t.export}},{key:"load",value:function(t){return b(this.list,t),this}},{key:"exist",value:function(t){return E(this.list,t)}},{key:"get",value:function(t){return this.list[t]}},{key:"remove",value:function(t){delete this.list[t]}},{key:"resolve",value:function(t){return Promise.resolve(this.get(t))}},{key:"set",value:function(t,e){return this.list[t]=e,this}}]),t}(),V=function(t,e){b(t,{path:r(o,n.path,t.path,e.path),export:r(o,n.export,t.export,e.export),resolver:r(i,n.resolver,t.resolver,e.resolver),extension:r(o,n.extension,t.extension,e.extension),withObject:r(c,n.withObject,t.withObject,e.withObject),rmWhitespace:r(c,n.rmWhitespace,t.rmWhitespace,e.rmWhitespace),watch:r(c,n.watch,t.watch,e.watch),token:b({},n.token,t.token,e.token),vars:b({},n.vars,t.vars,e.vars)})},z=function t(u){var s={},a={};V(s,u||{});var h=new K(s),f=new _(s),l=new Y(s),p=new q(s,l,f),v=function(t){return V(s,t),h.configure(s,a),f.configure(s),l.configure(s),p.configure(s),s},d=function(t,e){return p.get(t).then((function(t){return t.call(e,e,e.getComponent(),e.getBuffer(),m)}))},g=function(t,e){var n=y(t,s.extension),r=h.create(e);return d(n,r).then((function(t){if(r.getExtend()){r.setExtend(!1);var e=r.getLayout(),n=r.clone();return g(e,n)}return t}))},w=function(t){h.helpers(b(a,t||{}))};return w({require:function(t){return function(t){var e=y(t,s.extension),n=h.create({});return d(e,n).then((function(){return n.getMacro()}))}(t)},render:function(t,e){return g(t,e)}}),{render:g,helpers:w,configure:v,compile:function(t,e){return f.compile(t,e)},create:function(e){return t(e)},preload:function(t){return l.load(t)},context:h,__express:function(t,u,s){i(u)&&(s=u,u={});var a=b({},(u=u||{}).settings),h=r(o,n.path,a.views),f=r(c,n.cache,a["view cache"]),l=b({},a["view options"]),p=e.relative(h,t);return l.path=h,l.cache=f,v(l),g(p,u).then((function(t){s(null,t)})).catch((function(t){s(t)}))}}}({}),G=z.context,H=z.render,I=z.helpers,J=z.configure,Q=z.compile,Z=z.create,tt=z.preload,et=z.__express;t.__express=et,t.compile=Q,t.configure=J,t.context=G,t.create=Z,t.element=$,t.helpers=I,t.preload=tt,t.render=H,t.safeValue=m,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ejs={})}(this,(function(t){"use strict";var e={},n={};function r(t){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(t)}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,u(r.key),r)}}function c(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function u(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}n.export="ejsPrecompiled",n.watch=!1,n.path="views",n.resolver=null,n.extension="ejs",n.rmWhitespace=!0,n.withObject=!0,n.vars={SCOPE:"ejs",COMPONENT:"ui",EXTEND:"$$e",BUFFER:"$$a",LAYOUT:"$$l",BLOCKS:"$$b",MACRO:"$$m",SAFE:"$$v"},n.token={start:"<%",end:"%>",regex:"([\\s\\S]+?)"};var s=function(){var t=[].slice.call(arguments),e=t.shift();return t.filter(e).pop()},a=function(t){return"function"==typeof t},h=function(t){return"string"==typeof t},f=function(t){return"boolean"==typeof t},l=function(t){return"object"===r(t)},p=function(t){return void 0===t},v="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),m=function(){return v},d={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"},g={"&":"&","<":"<",">":">",'"':""","'":"'"},y=function(t){return new RegExp(["[",Object.keys(t).join(""),"]"].join(""),"g")},b=y(g),w=y(d),x=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return(""+t).replace(b,(function(t){return g[t]}))},k=function(t,e,n){return null==(n=t)?"":e?x(n):n},j=function(t,e){var n=t,r=e.split("."),o=r.pop();return r.forEach((function(t){n=n[t]=n[t]||{}})),[n,o]},E=function(t,e){var n=t.split(".").pop();return n!==e&&(t=[t,e].join(".")),t},O=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];var r=e.shift();return e.filter((function(t){return t})).reduce((function(t,e){return Object.assign(t,e)}),r)},F=function(){},S=function(t,e){var n;for(n in t)R(t,n)&&e(t[n],n,t)},B=function(t,e){return function(t,e,n){var r=t instanceof Array,o=r?[]:{};return S(t,(function(t,n,i){var c=e(t,n,i);!1===p(c)&&(r?o.push(c):o[n]=c)})),o}(t,(function(t,n){if(-1===e.indexOf(n))return t}))},P=function(t,e,n){return Promise.resolve(t).then(e.bind(n))},R=function(t,e){return t&&t.hasOwnProperty(e)},$=["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"],M=" ",T='"',C="/",U="<",A=">",_=function(t,e,n){var r=[],o=-1===$.indexOf(t),i=function(t,e,n){var r=[];return S(t,(function(t,n,o){var i=e(t,n,o);!1===p(i)&&r.push(i)})),r}(e,(function(t,e){if(null!=t)return[x(e),[T,x(t),T].join("")].join("=")})).join(M);return r.push([U,t,M,i,A].join("")),n&&r.push(n instanceof Array?n.join(""):n),o&&r.push([U,C,t,A].join("")),r.join("")},L=[{symbol:"-",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,",1))\n").concat(this.BUFFER,"('")}},{symbol:"=",format:function(t){return"')\n".concat(this.BUFFER,"(").concat(this.SAFE,"(").concat(t,"))\n").concat(this.BUFFER,"('")}},{symbol:"#",format:function(t){return"')\n/**".concat(t,"**/\n").concat(this.BUFFER,"('")}},{symbol:"",format:function(t){return"')\n".concat(t.trim(),"\n").concat(this.BUFFER,"('")}}],N=function(){function t(e){o(this,t),this.configure(e)}return c(t,[{key:"configure",value:function(t){var e=this;this.withObject=t.withObject,this.rmWhitespace=t.rmWhitespace,this.token=t.token,this.vars=t.vars,this.matches=[],this.formats=[],this.slurp={match:"[ \\t]*",start:[this.token.start,"_"],end:["_",this.token.end]},L.forEach((function(t){e.matches.push(e.token.start.concat(t.symbol).concat(e.token.regex).concat(e.token.end)),e.formats.push(t.format.bind(e.vars))})),this.regex=new RegExp(this.matches.join("|").concat("|$"),"g"),this.slurpStart=new RegExp([this.slurp.match,this.slurp.start.join("")].join(""),"gm"),this.slurpEnd=new RegExp([this.slurp.end.join(""),this.slurp.match].join(""),"gm")}},{key:"truncate",value:function(t){return t&&t.replace(/^(?:\r\n|\r|\n)/,"")}},{key:"compile",value:function(t,e){var n=this,r=this.vars,o=r.SCOPE,i=r.SAFE,c=r.BUFFER,u=r.COMPONENT;this.rmWhitespace&&(t=t.replace(/[\r\n]+/g,"\n").replace(/^\s+|\s+$/gm,"")),t=t.replace(this.slurpStart,this.token.start).replace(this.slurpEnd,this.token.end);var s,a,h,f="".concat(c,"('");s=this.regex,a=function(e,r,o){f+=(""+t.slice(r,o)).replace(w,(function(t){return"\\"+d[t]})),e.forEach((function(t,e){t&&(f+=n.formats[e](t))}))},h=0,t.replace(s,(function(){var t=[].slice.call(arguments,0,-1),e=t.pop(),n=t.shift();return a(t,h,e),h=e+n.length,n})),f="try{".concat(f+="');","}catch(e){console.info(e)}"),this.withObject&&(f="with(".concat(o,"){").concat(f,"}")),f="".concat(c,".start();").concat(f,"return ").concat(c,".end();"),f+="\n//# sourceURL=".concat(e);var l=null;try{(l=new Function(o,u,c,i,f)).source="(function(".concat(o,",").concat(u,",").concat(c,",").concat(i,"){\n").concat(f,"\n})")}catch(t){throw t.filename=e,t.source=f,t}return l}}]),t}(),W=function(t,e){return e=(e=[t,e].join("/")).replace(/\/\//g,"/")},q=function(t,e){return fetch(W(t,e)).then((function(t){return t.text()}))},D=function(t,n){return new Promise((function(r,o){e.readFile(W(t,n),(function(t,e){t?o(t):r(e.toString())}))}))},K=function(){function t(e,n,r){o(this,t),this.cache=n,this.watcher=null,this.compiler=r,this.configure(e)}return c(t,[{key:"configure",value:function(t){var e=this;this.path=t.path,this.chokidar=t.chokidar,this.resolver=a(t.resolver)?t.resolver:m()?D:q,t.watch&&t.chokidar&&m()&&(this.watcher&&this.watcher.unwatch("."),this.watcher=this.chokidar.watch(".",{cwd:this.path}).on("change",(function(t){e.cache.remove(t)})).on("error",(function(t){console.log("watcher error: "+t)})))}},{key:"resolve",value:function(t){return this.resolver(this.path,t)}},{key:"result",value:function(t,e){return this.cache.set(t,e),e}},{key:"compile",value:function(t,e){return a(t)?t:this.compiler.compile(t,e)}},{key:"get",value:function(t){var e=this;if(this.cache.exist(t))return this.cache.resolve(t);var n=this.resolve(t).then((function(n){return e.result(t,e.compile(n,t))}));return this.result(t,n)}}]),t}(),X=function(t){return Promise.all(t).then((function(t){return t.join("")}))},Y=function(){function t(e){o(this,t),this.configure(e)}return c(t,[{key:"configure",value:function(t,e){var n=t.vars,r=n.EXTEND,o=n.LAYOUT,i=n.BLOCKS,c=n.BUFFER,u=n.MACRO,s=n.COMPONENT;function f(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.initBlocks(),this.initMacro(),O(this,t)}this.create=function(t){return new f(t)},this.helpers=function(t){O(f.prototype,t)},f.prototype=O({},e||{}),f.define=f.method=function(t,e,n,r,o){return Object.defineProperty(f.prototype,t,{value:e,writable:n||!1,configurable:r||!1,enumerable:o||!1})},f.define(c,function(){var t=[],e=[];function n(t){e.push(t)}return n.start=function(){e=[]},n.backup=function(){t.push(e.concat()),e=[]},n.restore=function(){var n=e.concat();return e=t.pop(),X(n)},n.error=function(t){throw t},n.end=function(){return X(e)},n}()),f.define(i,{},!0),f.define(u,{},!0),f.define(o,!1,!0),f.define(r,!1,!0),f.method("initBlocks",(function(){this[i]={}})),f.method("initMacro",(function(){this[u]={}})),f.method("getMacro",(function(){return this[u]})),f.method("getBuffer",(function(){return this[c]})),f.method("getComponent",(function(){var t=this;return s in t?function(){return t[s].apply(t,arguments)}:function(){console.log("%s function not defined",s)}})),f.method("getBlocks",(function(){return this[i]})),f.method("setExtend",(function(t){this[r]=t})),f.method("getExtend",(function(){return this[r]})),f.method("setLayout",(function(t){this[o]=t})),f.method("getLayout",(function(){return this[o]})),f.method("clone",(function(t){var e=[o,r,c];return!0===t&&e.push(i),B(this,e)})),f.method("extend",(function(t){this.setExtend(!0),this.setLayout(t)})),f.method("echo",(function(){var t=this.getBuffer(),e=[].slice.call(arguments);e.forEach(t)})),f.method("fn",(function(t){var e=this.getBuffer(),n=this;return function(){return e.backup(),a(t)&&t.apply(n,arguments),e.restore()}})),f.method("get",(function(t,e){var n=j(this,t),r=n.shift(),o=n.pop();return R(r,o)?r[o]:e})),f.method("set",(function(t,e){var n=j(this,t),r=n.shift(),o=n.pop();return this.getExtend()&&R(r,o)?r[o]:r[o]=e})),f.method("macro",(function(t,e){var n=this.getMacro(),r=this.fn(e),o=this;n[t]=function(){return o.echo(r.apply(void 0,arguments))}})),f.method("call",(function(t){var e=this.getMacro(),n=e[t],r=[].slice.call(arguments,1);if(a(n))return n.apply(n,r)})),f.method("block",(function(t,e){var n=this,r=this.getBlocks();if(r[t]=r[t]||[],r[t].push(this.fn(e)),!this.getExtend()){var o=Object.assign([],r[t]),i=function(){return o.shift()};this.echo(i()(function t(){var e=i();return e?function(){n.echo(e(t()))}:F}()))}})),f.method("include",(function(t,e,n){var r=!1===n?{}:this.clone(!0),o=O(r,e||{}),i=this.render(t,o);this.echo(i)})),f.method("use",(function(t,e){var n=this.require(t);this.echo(P(n,(function(t){var n=this.getMacro();S(t,(function(t,r){n[[e,r].join(".")]=t}))}),this))})),f.method("async",(function(t,e){this.echo(P(t,(function(t){return this.fn(e)(t)}),this))})),f.method("node",(function(t,e,n){return _(t,e,n)})),f.method("el",(function(t,e,n){a(n)&&(n=this.fn(n)()),this.echo(P(n,(function(n){return _(t,e,n)}),this))})),f.method("each",(function(t,e){h(t)&&(t=this.get(t,[])),S(t,e)}))}}]),t}(),V="undefined"!=typeof globalThis?globalThis:window||self,z=function(){function t(e){var n,r,i;o(this,t),n=this,i={},(r=u(r="list"))in n?Object.defineProperty(n,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[r]=i,this.configure(e),!1===m()&&this.load(V[this.namespace])}return c(t,[{key:"configure",value:function(t){this.list={},this.namespace=t.export}},{key:"load",value:function(t){return O(this.list,t),this}},{key:"exist",value:function(t){return R(this.list,t)}},{key:"get",value:function(t){return this.list[t]}},{key:"remove",value:function(t){delete this.list[t]}},{key:"resolve",value:function(t){return Promise.resolve(this.get(t))}},{key:"set",value:function(t,e){return this.list[t]=e,this}}]),t}(),G=function(t,e){O(t,{path:s(h,n.path,t.path,e.path),export:s(h,n.export,t.export,e.export),resolver:s(a,n.resolver,t.resolver,e.resolver),extension:s(h,n.extension,t.extension,e.extension),withObject:s(f,n.withObject,t.withObject,e.withObject),rmWhitespace:s(f,n.rmWhitespace,t.rmWhitespace,e.rmWhitespace),watch:s(f,n.watch,t.watch,e.watch),chokidar:s(l,n.export,t.export,e.export),token:O({},n.token,t.token,e.token),vars:O({},n.vars,t.vars,e.vars)})},H=function t(r){var o={},i={};G(o,r||{});var c=new Y(o),u=new N(o),l=new z(o),p=new K(o,l,u),v=function(t){return G(o,t),c.configure(o,i),u.configure(o),l.configure(o),p.configure(o),o},m=function(t,e){return p.get(t).then((function(t){return t.call(e,e,e.getComponent(),e.getBuffer(),k)}))},d=function t(e,n){var r=E(e,o.extension),i=c.create(n);return m(r,i).then((function(e){if(i.getExtend()){i.setExtend(!1);var n=i.getLayout(),r=i.clone();return t(n,r)}return e}))},g=function(t){c.helpers(O(i,t||{}))};return g({require:function(t){var e=E(t,o.extension),n=c.create({});return m(e,n).then((function(){return n.getMacro()}))},render:d}),{context:c,render:d,helpers:g,configure:v,compile:function(t,e){return u.compile(t,e)},create:t,preload:function(t){return l.load(t)},__express:function(t,r,o){a(r)&&(o=r,r={});var i=O({},(r=r||{}).settings),c=s(h,n.path,i.views),u=s(f,n.cache,i["view cache"]),l=O({},i["view options"]),p=e.relative(c,t);return l.path=c,l.cache=u,v(l),d(p,r).then((function(t){o(null,t)})).catch((function(t){o(t)}))}}},I=H({}),J=I.context,Q=I.render,Z=I.helpers,tt=I.configure,et=I.compile,nt=I.preload,rt=I.__express;t.__express=rt,t.compile=et,t.configure=tt,t.context=J,t.create=H,t.element=_,t.helpers=Z,t.preload=nt,t.render=Q,t.safeValue=k,Object.defineProperty(t,"__esModule",{value:!0})}));
|
package/element.d.ts
CHANGED
package/global.d.ts
CHANGED
|
@@ -1,44 +1,91 @@
|
|
|
1
|
+
declare function expressCallback(
|
|
2
|
+
error: null | object,
|
|
3
|
+
content: string
|
|
4
|
+
): undefined
|
|
5
|
+
|
|
1
6
|
declare global {
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export const context: any
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param name
|
|
15
|
+
* @param options
|
|
16
|
+
* @param callback
|
|
17
|
+
*/
|
|
18
|
+
export function __express(
|
|
19
|
+
name: string,
|
|
20
|
+
options: object,
|
|
21
|
+
callback: typeof expressCallback
|
|
22
|
+
): Promise<any>
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @param name
|
|
27
|
+
* @param data
|
|
28
|
+
*/
|
|
29
|
+
export function render(name: string, data: object): Promise<any>
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @param options
|
|
34
|
+
*/
|
|
35
|
+
export function configure(options: object): object
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @param methods
|
|
40
|
+
*/
|
|
41
|
+
export function helpers(methods: object): any
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @param list
|
|
46
|
+
*/
|
|
47
|
+
export function preload(list: object): any
|
|
48
|
+
|
|
2
49
|
/**
|
|
3
50
|
* extend layout with blocks in current template file
|
|
4
51
|
* @param layout
|
|
5
52
|
*/
|
|
6
|
-
function extend(layout: string)
|
|
53
|
+
function extend(layout: string): any
|
|
7
54
|
|
|
8
55
|
/**
|
|
9
56
|
* define block with custom **name** and callback
|
|
10
57
|
* @param name
|
|
11
58
|
* @param [callback]
|
|
12
59
|
*/
|
|
13
|
-
function block(name: string, callback?)
|
|
60
|
+
function block(name: string, callback?): any
|
|
14
61
|
|
|
15
62
|
/**
|
|
16
63
|
* set property in current scope
|
|
17
64
|
* @param path
|
|
18
65
|
* @param value
|
|
19
66
|
*/
|
|
20
|
-
function set(path: string, value: any)
|
|
67
|
+
function set(path: string, value: any): any
|
|
21
68
|
|
|
22
69
|
/**
|
|
23
70
|
* get property in current scope
|
|
24
71
|
* @param path
|
|
25
72
|
* @param defaults
|
|
26
73
|
*/
|
|
27
|
-
function get(path: string, defaults?: any)
|
|
74
|
+
function get(path: string, defaults?: any): any
|
|
28
75
|
|
|
29
76
|
/**
|
|
30
77
|
* import macro from file **path** and set to current scope **name** property
|
|
31
78
|
* @param path
|
|
32
79
|
* @param name
|
|
33
80
|
*/
|
|
34
|
-
function use(path: string, name: string)
|
|
81
|
+
function use(path: string, name: string): any
|
|
35
82
|
|
|
36
83
|
/**
|
|
37
84
|
* define macro function with custom **name**
|
|
38
85
|
* @param name
|
|
39
86
|
* @param callback
|
|
40
87
|
*/
|
|
41
|
-
function macro(name: string, callback)
|
|
88
|
+
function macro(name: string, callback: any): any
|
|
42
89
|
|
|
43
90
|
/**
|
|
44
91
|
* call macro function
|
|
@@ -46,20 +93,20 @@ declare global {
|
|
|
46
93
|
* @param props
|
|
47
94
|
* @param callback
|
|
48
95
|
*/
|
|
49
|
-
function call(name: string, props?: object, callback
|
|
96
|
+
function call(name: string, props?: object, callback?: any): any
|
|
50
97
|
|
|
51
98
|
/**
|
|
52
99
|
* asynchronous template execution
|
|
53
100
|
* @param promise
|
|
54
101
|
* @param callback
|
|
55
102
|
*/
|
|
56
|
-
function async(promise: Promise<any>, callback
|
|
103
|
+
function async(promise: Promise<any>, callback?: any): any
|
|
57
104
|
|
|
58
105
|
/**
|
|
59
106
|
* asynchronous template execution
|
|
60
107
|
* @param callback
|
|
61
108
|
*/
|
|
62
|
-
function fn(callback: Function)
|
|
109
|
+
function fn(callback: Function): any
|
|
63
110
|
|
|
64
111
|
/**
|
|
65
112
|
*
|
|
@@ -67,13 +114,13 @@ declare global {
|
|
|
67
114
|
* @param {object} attrs
|
|
68
115
|
* @param {function} content
|
|
69
116
|
*/
|
|
70
|
-
function el(tag: string, attrs?: object, content?: any)
|
|
117
|
+
function el(tag: string, attrs?: object, content?: any): any
|
|
71
118
|
|
|
72
119
|
/**
|
|
73
120
|
* buffer output
|
|
74
|
-
* @param
|
|
121
|
+
* @param args
|
|
75
122
|
*/
|
|
76
|
-
function echo(...any)
|
|
123
|
+
function echo(...args: any[]): any
|
|
77
124
|
|
|
78
125
|
/**
|
|
79
126
|
* append rendered template from file
|
|
@@ -81,21 +128,21 @@ declare global {
|
|
|
81
128
|
* @param data
|
|
82
129
|
* @param cx
|
|
83
130
|
*/
|
|
84
|
-
function include(path: string, data?: object, cx?: boolean)
|
|
131
|
+
function include(path: string, data?: object, cx?: boolean): any
|
|
85
132
|
|
|
86
133
|
/**
|
|
87
134
|
*
|
|
88
135
|
* @param value
|
|
89
136
|
* @param callback
|
|
90
137
|
*/
|
|
91
|
-
function each(value: any, callback: Function)
|
|
138
|
+
function each(value: any, callback: Function): any
|
|
92
139
|
|
|
93
140
|
/**
|
|
94
141
|
* define block with custom **name** and callback
|
|
95
142
|
* @param {string} name
|
|
96
143
|
* @param {object} [props]
|
|
97
144
|
*/
|
|
98
|
-
function ui(name: string, props
|
|
145
|
+
function ui(name: string, props?: object): any
|
|
99
146
|
}
|
|
100
147
|
|
|
101
148
|
export = global
|
package/package.json
CHANGED
|
@@ -3,15 +3,12 @@
|
|
|
3
3
|
"description": "EJS Templates",
|
|
4
4
|
"homepage": "https://github.com/kosatyi/ejs",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.51",
|
|
7
7
|
"main": "dist/cjs/index.js",
|
|
8
8
|
"module": "dist/esm/index.js",
|
|
9
9
|
"browser": "dist/umd/index.js",
|
|
10
10
|
"minified": "dist/umd/index.min.js",
|
|
11
11
|
"author": "Stepan Kosatyi (https://kosatyi.com)",
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"chokidar": "^3.5.3"
|
|
14
|
-
},
|
|
15
12
|
"exports": {
|
|
16
13
|
".": {
|
|
17
14
|
"types": "./index.d.ts",
|