ecto 4.3.0 → 4.4.1
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/README.md +34 -0
- package/dist/ecto.d.ts +22 -15
- package/dist/ecto.js +126 -104
- package/package.json +12 -11
package/README.md
CHANGED
|
@@ -40,6 +40,7 @@ Ecto is a modern template consolidation engine that enables the best template en
|
|
|
40
40
|
* [Liquid](#liquid)
|
|
41
41
|
* [FrontMatter Helper Functions](#frontmatter-helper-functions)
|
|
42
42
|
* [Caching on Rendering](#caching-on-rendering)
|
|
43
|
+
* [Emitting Events](#emitting-events)
|
|
43
44
|
* [How to Contribute](#how-to-contribute)
|
|
44
45
|
* [License](#license)
|
|
45
46
|
|
|
@@ -608,6 +609,39 @@ const result = await ecto.render(source, data);
|
|
|
608
609
|
console.log(result); // <h1>Hello John Doe!</h1>
|
|
609
610
|
```
|
|
610
611
|
|
|
612
|
+
# Emitting Events
|
|
613
|
+
|
|
614
|
+
Ecto has a built-in event emitter that allows you to listen for events that occur during the rendering process. This is useful for debugging and monitoring the rendering process. The following events are emitted:
|
|
615
|
+
|
|
616
|
+
- `cacheHit` - Emitted when a cached result is found and returned.
|
|
617
|
+
- `cacheMiss` - Emitted when a cached result is not found and the template needs to be rendered.
|
|
618
|
+
- `info` - Emitted for informational messages.
|
|
619
|
+
- `warn` - Emitted for warning messages.
|
|
620
|
+
- `error` - Emitted for error messages.
|
|
621
|
+
|
|
622
|
+
You can listen for these events by using the `on` method of the `Ecto` instance:
|
|
623
|
+
|
|
624
|
+
```javascript
|
|
625
|
+
import { Ecto } from 'ecto';
|
|
626
|
+
const ecto = new Ecto();
|
|
627
|
+
ecto.on('cacheHit', (data) => {
|
|
628
|
+
console.log('Cache hit:', data);
|
|
629
|
+
});
|
|
630
|
+
ecto.on('cacheMiss', (data) => {
|
|
631
|
+
console.log('Cache miss:', data);
|
|
632
|
+
});
|
|
633
|
+
ecto.on('warn', (data) => {
|
|
634
|
+
console.warn('Warning:', data);
|
|
635
|
+
});
|
|
636
|
+
ecto.on('error', (data) => {
|
|
637
|
+
console.error('Error:', data);
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
const source = "<h1>Hello <%= firstName%> <%= lastName %>!</h1>";
|
|
641
|
+
const data = { firstName: "John", lastName: "Doe" };
|
|
642
|
+
await ecto.render(source, data); // <h1>Hello John Doe!</h1>
|
|
643
|
+
```
|
|
644
|
+
|
|
611
645
|
# How to Contribute
|
|
612
646
|
|
|
613
647
|
To contribute please ready our [CONTRIBUTING.md](CONTRIBUTING.md) guide. Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
package/dist/ecto.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { HookifiedOptions, Hookified } from 'hookified';
|
|
1
2
|
import { Cacheable, CacheableMemory } from 'cacheable';
|
|
2
3
|
|
|
3
4
|
declare class EngineMap {
|
|
@@ -14,7 +15,7 @@ declare class BaseEngine {
|
|
|
14
15
|
opts?: any;
|
|
15
16
|
engine: any;
|
|
16
17
|
rootTemplatePath?: string;
|
|
17
|
-
private
|
|
18
|
+
private _extensions;
|
|
18
19
|
getExtensions(): string[];
|
|
19
20
|
setExtensions(extensions: string[]): void;
|
|
20
21
|
deleteExtension(name: string): void;
|
|
@@ -104,19 +105,25 @@ type EctoOptions = {
|
|
|
104
105
|
* @default false
|
|
105
106
|
*/
|
|
106
107
|
cacheSync?: boolean | CacheableMemory;
|
|
107
|
-
};
|
|
108
|
-
declare
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
private readonly
|
|
116
|
-
private readonly
|
|
117
|
-
private
|
|
118
|
-
private
|
|
119
|
-
private
|
|
108
|
+
} & HookifiedOptions;
|
|
109
|
+
declare enum EctoEvents {
|
|
110
|
+
cacheHit = "cacheHit",
|
|
111
|
+
cacheMiss = "cacheMiss",
|
|
112
|
+
warn = "warn",
|
|
113
|
+
error = "error"
|
|
114
|
+
}
|
|
115
|
+
declare class Ecto extends Hookified {
|
|
116
|
+
private readonly _mapping;
|
|
117
|
+
private readonly _engines;
|
|
118
|
+
private _cache;
|
|
119
|
+
private _cacheSync;
|
|
120
|
+
private _defaultEngine;
|
|
121
|
+
private readonly _ejs;
|
|
122
|
+
private readonly _markdown;
|
|
123
|
+
private readonly _pug;
|
|
124
|
+
private readonly _nunjucks;
|
|
125
|
+
private readonly _handlebars;
|
|
126
|
+
private readonly _liquid;
|
|
120
127
|
/**
|
|
121
128
|
* Ecto constructor
|
|
122
129
|
* @param {EctoOptions} [options] - The options for the ecto engine
|
|
@@ -305,4 +312,4 @@ declare class Ecto {
|
|
|
305
312
|
private writeFileSync;
|
|
306
313
|
}
|
|
307
314
|
|
|
308
|
-
export { Ecto, type EctoOptions };
|
|
315
|
+
export { Ecto, EctoEvents, type EctoOptions };
|
package/dist/ecto.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/ecto.ts
|
|
2
2
|
import fs2 from "fs";
|
|
3
|
+
import { Hookified } from "hookified";
|
|
3
4
|
import { Writr as Writr2 } from "writr";
|
|
4
5
|
import { Cacheable, CacheableMemory } from "cacheable";
|
|
5
6
|
|
|
@@ -58,23 +59,23 @@ var BaseEngine = class {
|
|
|
58
59
|
opts = void 0;
|
|
59
60
|
engine;
|
|
60
61
|
rootTemplatePath = void 0;
|
|
61
|
-
|
|
62
|
+
_extensions = new Array();
|
|
62
63
|
getExtensions() {
|
|
63
|
-
return this.
|
|
64
|
+
return this._extensions;
|
|
64
65
|
}
|
|
65
66
|
setExtensions(extensions) {
|
|
66
|
-
this.
|
|
67
|
+
this._extensions = new Array();
|
|
67
68
|
for (const extension of extensions) {
|
|
68
69
|
const newExtension = extension.trim().toLowerCase();
|
|
69
|
-
if (!this.
|
|
70
|
-
this.
|
|
70
|
+
if (!this._extensions.includes(newExtension)) {
|
|
71
|
+
this._extensions.push(newExtension);
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
deleteExtension(name) {
|
|
75
|
-
for (const [index, extension] of this.
|
|
76
|
+
for (const [index, extension] of this._extensions.entries()) {
|
|
76
77
|
if (name.toLowerCase().trim() === extension) {
|
|
77
|
-
this.
|
|
78
|
+
this._extensions.splice(index, 1);
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
}
|
|
@@ -289,50 +290,54 @@ var Liquid = class extends BaseEngine {
|
|
|
289
290
|
};
|
|
290
291
|
|
|
291
292
|
// src/ecto.ts
|
|
292
|
-
var
|
|
293
|
-
|
|
294
|
-
|
|
293
|
+
var EctoEvents = /* @__PURE__ */ ((EctoEvents2) => {
|
|
294
|
+
EctoEvents2["cacheHit"] = "cacheHit";
|
|
295
|
+
EctoEvents2["cacheMiss"] = "cacheMiss";
|
|
296
|
+
EctoEvents2["warn"] = "warn";
|
|
297
|
+
EctoEvents2["error"] = "error";
|
|
298
|
+
return EctoEvents2;
|
|
299
|
+
})(EctoEvents || {});
|
|
300
|
+
var Ecto = class extends Hookified {
|
|
301
|
+
_mapping = new EngineMap();
|
|
302
|
+
_engines = new Array();
|
|
295
303
|
// Cacheable instance for caching rendered templates
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
304
|
+
_cache;
|
|
305
|
+
_cacheSync;
|
|
306
|
+
_defaultEngine = "ejs";
|
|
299
307
|
// Engines
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
308
|
+
_ejs;
|
|
309
|
+
_markdown;
|
|
310
|
+
_pug;
|
|
311
|
+
_nunjucks;
|
|
312
|
+
_handlebars;
|
|
313
|
+
_liquid;
|
|
306
314
|
/**
|
|
307
315
|
* Ecto constructor
|
|
308
316
|
* @param {EctoOptions} [options] - The options for the ecto engine
|
|
309
317
|
*/
|
|
310
318
|
// eslint-disable-next-line complexity
|
|
311
319
|
constructor(options) {
|
|
312
|
-
|
|
313
|
-
this.
|
|
314
|
-
this.
|
|
315
|
-
this.
|
|
316
|
-
this.
|
|
317
|
-
this.
|
|
318
|
-
this.
|
|
320
|
+
super();
|
|
321
|
+
this._ejs = new EJS(options?.engineOptions?.ejs);
|
|
322
|
+
this._markdown = new Markdown(options?.engineOptions?.markdown);
|
|
323
|
+
this._pug = new Pug(options?.engineOptions?.pug);
|
|
324
|
+
this._nunjucks = new Nunjucks(options?.engineOptions?.nunjucks);
|
|
325
|
+
this._handlebars = new Handlebars(options?.engineOptions?.handlebars);
|
|
326
|
+
this._liquid = new Liquid(options?.engineOptions?.liquid);
|
|
327
|
+
this._engines.push(this._ejs, this._markdown, this._pug, this._nunjucks, this._handlebars, this._liquid);
|
|
319
328
|
this.registerEngineMappings();
|
|
320
|
-
if (options?.cache
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
this.__cache = options.cache;
|
|
325
|
-
}
|
|
329
|
+
if (options?.cache === true) {
|
|
330
|
+
this._cache = new Cacheable();
|
|
331
|
+
} else if (options?.cache instanceof Cacheable) {
|
|
332
|
+
this._cache = options.cache;
|
|
326
333
|
}
|
|
327
|
-
if (options?.cacheSync
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
this.__cacheSync = options.cacheSync;
|
|
332
|
-
}
|
|
334
|
+
if (options?.cacheSync === true) {
|
|
335
|
+
this._cacheSync = new CacheableMemory();
|
|
336
|
+
} else if (options?.cacheSync instanceof CacheableMemory) {
|
|
337
|
+
this._cacheSync = options.cacheSync;
|
|
333
338
|
}
|
|
334
339
|
if (options !== void 0 && this.isValidEngine(options.defaultEngine)) {
|
|
335
|
-
this.
|
|
340
|
+
this._defaultEngine = options.defaultEngine;
|
|
336
341
|
}
|
|
337
342
|
}
|
|
338
343
|
/**
|
|
@@ -340,7 +345,7 @@ var Ecto = class {
|
|
|
340
345
|
* @returns {string} - the engine name such as 'ejs', 'markdown', 'pug', 'nunjucks', 'handlebars', 'liquid'
|
|
341
346
|
*/
|
|
342
347
|
get defaultEngine() {
|
|
343
|
-
return this.
|
|
348
|
+
return this._defaultEngine;
|
|
344
349
|
}
|
|
345
350
|
/**
|
|
346
351
|
* Set the default engine
|
|
@@ -349,7 +354,9 @@ var Ecto = class {
|
|
|
349
354
|
set defaultEngine(value) {
|
|
350
355
|
value = value.toLowerCase().trim();
|
|
351
356
|
if (this.isValidEngine(value)) {
|
|
352
|
-
this.
|
|
357
|
+
this._defaultEngine = value;
|
|
358
|
+
} else {
|
|
359
|
+
this.emit("warn" /* warn */, `Invalid engine name: ${value}. Defaulting to ${this._defaultEngine}.`);
|
|
353
360
|
}
|
|
354
361
|
}
|
|
355
362
|
/**
|
|
@@ -357,77 +364,77 @@ var Ecto = class {
|
|
|
357
364
|
* @returns {Cacheable | undefined} - The cacheable instance or undefined if caching is disabled
|
|
358
365
|
*/
|
|
359
366
|
get cache() {
|
|
360
|
-
return this.
|
|
367
|
+
return this._cache;
|
|
361
368
|
}
|
|
362
369
|
/**
|
|
363
370
|
* Set the cacheable instance
|
|
364
371
|
* @param {Cacheable | undefined} value - The cacheable instance to set. If set to undefined, caching will be disabled.
|
|
365
372
|
*/
|
|
366
373
|
set cache(value) {
|
|
367
|
-
this.
|
|
374
|
+
this._cache = value;
|
|
368
375
|
}
|
|
369
376
|
/**
|
|
370
377
|
* Get the cacheable memory instance
|
|
371
378
|
* @returns {CacheableMemory | undefined} - The cacheable memory instance or undefined if caching is disabled
|
|
372
379
|
*/
|
|
373
380
|
get cacheSync() {
|
|
374
|
-
return this.
|
|
381
|
+
return this._cacheSync;
|
|
375
382
|
}
|
|
376
383
|
/**
|
|
377
384
|
* Set the cacheable memory instance
|
|
378
385
|
* @param {CacheableMemory | undefined} value - The cacheable memory instance to set. If set to undefined, caching will be disabled.
|
|
379
386
|
*/
|
|
380
387
|
set cacheSync(value) {
|
|
381
|
-
this.
|
|
388
|
+
this._cacheSync = value;
|
|
382
389
|
}
|
|
383
390
|
/**
|
|
384
391
|
* Get the Engine Mappings. This is used to map file extensions to engines
|
|
385
392
|
* @returns {EngineMap}
|
|
386
393
|
*/
|
|
387
394
|
get mappings() {
|
|
388
|
-
return this.
|
|
395
|
+
return this._mapping;
|
|
389
396
|
}
|
|
390
397
|
/**
|
|
391
398
|
* Get the EJS Engine
|
|
392
399
|
* @returns {EJS}
|
|
393
400
|
*/
|
|
394
401
|
get ejs() {
|
|
395
|
-
return this.
|
|
402
|
+
return this._ejs;
|
|
396
403
|
}
|
|
397
404
|
/**
|
|
398
405
|
* Get the Markdown Engine
|
|
399
406
|
* @returns {Markdown}
|
|
400
407
|
*/
|
|
401
408
|
get markdown() {
|
|
402
|
-
return this.
|
|
409
|
+
return this._markdown;
|
|
403
410
|
}
|
|
404
411
|
/**
|
|
405
412
|
* Get the Pug Engine
|
|
406
413
|
* @returns {Pug}
|
|
407
414
|
*/
|
|
408
415
|
get pug() {
|
|
409
|
-
return this.
|
|
416
|
+
return this._pug;
|
|
410
417
|
}
|
|
411
418
|
/**
|
|
412
419
|
* Get the Nunjucks Engine
|
|
413
420
|
* @returns {Nunjucks}
|
|
414
421
|
*/
|
|
415
422
|
get nunjucks() {
|
|
416
|
-
return this.
|
|
423
|
+
return this._nunjucks;
|
|
417
424
|
}
|
|
418
425
|
/**
|
|
419
426
|
* Get the Handlebars Engine
|
|
420
427
|
* @returns {Handlebars}
|
|
421
428
|
*/
|
|
422
429
|
get handlebars() {
|
|
423
|
-
return this.
|
|
430
|
+
return this._handlebars;
|
|
424
431
|
}
|
|
425
432
|
/**
|
|
426
433
|
* Get the Liquid Engine
|
|
427
434
|
* @returns {Liquid}
|
|
428
435
|
*/
|
|
429
436
|
get liquid() {
|
|
430
|
-
return this.
|
|
437
|
+
return this._liquid;
|
|
431
438
|
}
|
|
432
439
|
/**
|
|
433
440
|
* Async render the source with the data
|
|
@@ -440,27 +447,34 @@ var Ecto = class {
|
|
|
440
447
|
*/
|
|
441
448
|
// eslint-disable-next-line max-params
|
|
442
449
|
async render(source, data, engineName, rootTemplatePath, filePathOutput) {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
450
|
+
try {
|
|
451
|
+
const cacheKey = `${engineName ?? this._defaultEngine}-${source}-${JSON.stringify(data)}`;
|
|
452
|
+
if (this._cache) {
|
|
453
|
+
const cachedResult = await this._cache.get(cacheKey);
|
|
454
|
+
if (cachedResult) {
|
|
455
|
+
this.emit("cacheHit" /* cacheHit */, `Cache hit for key: ${cacheKey}`);
|
|
456
|
+
await this.writeFile(filePathOutput, cachedResult);
|
|
457
|
+
return cachedResult;
|
|
458
|
+
}
|
|
459
|
+
this.emit("cacheMiss" /* cacheMiss */, `Cache miss for key: ${cacheKey}`);
|
|
449
460
|
}
|
|
461
|
+
let result = "";
|
|
462
|
+
let renderEngineName = this._defaultEngine;
|
|
463
|
+
if (this.isValidEngine(engineName) && engineName !== void 0) {
|
|
464
|
+
renderEngineName = engineName;
|
|
465
|
+
}
|
|
466
|
+
const renderEngine = this.getRenderEngine(renderEngineName);
|
|
467
|
+
renderEngine.rootTemplatePath = rootTemplatePath;
|
|
468
|
+
result = await renderEngine.render(source, data);
|
|
469
|
+
if (this._cache) {
|
|
470
|
+
await this._cache.set(cacheKey, result);
|
|
471
|
+
}
|
|
472
|
+
await this.writeFile(filePathOutput, result);
|
|
473
|
+
return result;
|
|
474
|
+
} catch (error) {
|
|
475
|
+
this.emit("error" /* error */, error);
|
|
476
|
+
return "";
|
|
450
477
|
}
|
|
451
|
-
let result = "";
|
|
452
|
-
let renderEngineName = this.__defaultEngine;
|
|
453
|
-
if (this.isValidEngine(engineName) && engineName !== void 0) {
|
|
454
|
-
renderEngineName = engineName;
|
|
455
|
-
}
|
|
456
|
-
const renderEngine = this.getRenderEngine(renderEngineName);
|
|
457
|
-
renderEngine.rootTemplatePath = rootTemplatePath;
|
|
458
|
-
result = await renderEngine.render(source, data);
|
|
459
|
-
if (this.__cache) {
|
|
460
|
-
await this.__cache.set(cacheKey, result);
|
|
461
|
-
}
|
|
462
|
-
await this.writeFile(filePathOutput, result);
|
|
463
|
-
return result;
|
|
464
478
|
}
|
|
465
479
|
/**
|
|
466
480
|
* Synchronously render the source with the data
|
|
@@ -473,27 +487,34 @@ var Ecto = class {
|
|
|
473
487
|
*/
|
|
474
488
|
// eslint-disable-next-line max-params
|
|
475
489
|
renderSync(source, data, engineName, rootTemplatePath, filePathOutput) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
490
|
+
try {
|
|
491
|
+
const cacheKey = `${engineName ?? this._defaultEngine}-${source}-${JSON.stringify(data)}`;
|
|
492
|
+
if (this._cacheSync) {
|
|
493
|
+
const cachedResult = this._cacheSync.get(cacheKey);
|
|
494
|
+
if (cachedResult) {
|
|
495
|
+
this.emit("cacheHit" /* cacheHit */, `Cache hit for key: ${cacheKey}`);
|
|
496
|
+
this.writeFileSync(filePathOutput, cachedResult);
|
|
497
|
+
return cachedResult;
|
|
498
|
+
}
|
|
499
|
+
this.emit("cacheMiss" /* cacheMiss */, `Cache miss for key: ${cacheKey}`);
|
|
482
500
|
}
|
|
501
|
+
let result = "";
|
|
502
|
+
let renderEngineName = this._defaultEngine;
|
|
503
|
+
if (this.isValidEngine(engineName) && engineName !== void 0) {
|
|
504
|
+
renderEngineName = engineName;
|
|
505
|
+
}
|
|
506
|
+
const renderEngine = this.getRenderEngine(renderEngineName);
|
|
507
|
+
renderEngine.rootTemplatePath = rootTemplatePath;
|
|
508
|
+
result = renderEngine.renderSync(source, data);
|
|
509
|
+
if (this._cacheSync) {
|
|
510
|
+
this._cacheSync.set(cacheKey, result);
|
|
511
|
+
}
|
|
512
|
+
this.writeFileSync(filePathOutput, result);
|
|
513
|
+
return result;
|
|
514
|
+
} catch (error) {
|
|
515
|
+
this.emit("error" /* error */, error);
|
|
516
|
+
return "";
|
|
483
517
|
}
|
|
484
|
-
let result = "";
|
|
485
|
-
let renderEngineName = this.__defaultEngine;
|
|
486
|
-
if (this.isValidEngine(engineName) && engineName !== void 0) {
|
|
487
|
-
renderEngineName = engineName;
|
|
488
|
-
}
|
|
489
|
-
const renderEngine = this.getRenderEngine(renderEngineName);
|
|
490
|
-
renderEngine.rootTemplatePath = rootTemplatePath;
|
|
491
|
-
result = renderEngine.renderSync(source, data);
|
|
492
|
-
if (this.__cacheSync) {
|
|
493
|
-
this.__cacheSync.set(cacheKey, result);
|
|
494
|
-
}
|
|
495
|
-
this.writeFileSync(filePathOutput, result);
|
|
496
|
-
return result;
|
|
497
518
|
}
|
|
498
519
|
/**
|
|
499
520
|
* Render from a file path
|
|
@@ -561,10 +582,10 @@ var Ecto = class {
|
|
|
561
582
|
* @returns {string} - will return the engine name such as 'ejs', 'markdown', 'pug', 'nunjucks', 'handlebars', 'liquid'
|
|
562
583
|
*/
|
|
563
584
|
getEngineByFilePath(filePath) {
|
|
564
|
-
let result = this.
|
|
585
|
+
let result = this._defaultEngine;
|
|
565
586
|
if (filePath !== void 0) {
|
|
566
587
|
const extension = filePath.includes(".") ? filePath.slice(filePath.lastIndexOf(".") + 1) : "";
|
|
567
|
-
const engExtension = this.
|
|
588
|
+
const engExtension = this._mapping.getName(extension);
|
|
568
589
|
if (engExtension !== void 0) {
|
|
569
590
|
result = engExtension;
|
|
570
591
|
}
|
|
@@ -612,7 +633,7 @@ var Ecto = class {
|
|
|
612
633
|
*/
|
|
613
634
|
isValidEngine(engineName) {
|
|
614
635
|
let result = false;
|
|
615
|
-
if (engineName !== void 0 && this.
|
|
636
|
+
if (engineName !== void 0 && this._mapping.get(engineName) !== void 0) {
|
|
616
637
|
result = true;
|
|
617
638
|
}
|
|
618
639
|
return result;
|
|
@@ -622,9 +643,9 @@ var Ecto = class {
|
|
|
622
643
|
* @returns {void}
|
|
623
644
|
*/
|
|
624
645
|
registerEngineMappings() {
|
|
625
|
-
for (const eng of this.
|
|
646
|
+
for (const eng of this._engines) {
|
|
626
647
|
for (const name of eng.names) {
|
|
627
|
-
this.
|
|
648
|
+
this._mapping.set(name, eng.getExtensions());
|
|
628
649
|
}
|
|
629
650
|
}
|
|
630
651
|
}
|
|
@@ -634,35 +655,35 @@ var Ecto = class {
|
|
|
634
655
|
* @returns {EngineInterface}
|
|
635
656
|
*/
|
|
636
657
|
getRenderEngine(engineName) {
|
|
637
|
-
let result = this.
|
|
658
|
+
let result = this._ejs;
|
|
638
659
|
const cleanEngineName = engineName.trim().toLowerCase();
|
|
639
660
|
switch (cleanEngineName) {
|
|
640
661
|
case "markdown": {
|
|
641
|
-
result = this.
|
|
662
|
+
result = this._markdown;
|
|
642
663
|
break;
|
|
643
664
|
}
|
|
644
665
|
case "pug": {
|
|
645
|
-
result = this.
|
|
666
|
+
result = this._pug;
|
|
646
667
|
break;
|
|
647
668
|
}
|
|
648
669
|
case "nunjucks": {
|
|
649
|
-
result = this.
|
|
670
|
+
result = this._nunjucks;
|
|
650
671
|
break;
|
|
651
672
|
}
|
|
652
673
|
case "mustache": {
|
|
653
|
-
result = this.
|
|
674
|
+
result = this._handlebars;
|
|
654
675
|
break;
|
|
655
676
|
}
|
|
656
677
|
case "handlebars": {
|
|
657
|
-
result = this.
|
|
678
|
+
result = this._handlebars;
|
|
658
679
|
break;
|
|
659
680
|
}
|
|
660
681
|
case "liquid": {
|
|
661
|
-
result = this.
|
|
682
|
+
result = this._liquid;
|
|
662
683
|
break;
|
|
663
684
|
}
|
|
664
685
|
default: {
|
|
665
|
-
result = this.
|
|
686
|
+
result = this._ejs;
|
|
666
687
|
break;
|
|
667
688
|
}
|
|
668
689
|
}
|
|
@@ -723,5 +744,6 @@ var Ecto = class {
|
|
|
723
744
|
}
|
|
724
745
|
};
|
|
725
746
|
export {
|
|
726
|
-
Ecto
|
|
747
|
+
Ecto,
|
|
748
|
+
EctoEvents
|
|
727
749
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ecto",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.1",
|
|
4
4
|
"description": "Modern Template Consolidation Engine for EJS, Markdown, Pug, Nunjucks, Liquid, and Handlebars",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/ecto.js",
|
|
@@ -46,29 +46,30 @@
|
|
|
46
46
|
"liquidjs"
|
|
47
47
|
],
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@jaredwray/fumanchu": "^3.1.
|
|
50
|
-
"cacheable": "^1.10.
|
|
49
|
+
"@jaredwray/fumanchu": "^3.1.2",
|
|
50
|
+
"cacheable": "^1.10.4",
|
|
51
51
|
"ejs": "^3.1.10",
|
|
52
|
+
"hookified": "^1.11.0",
|
|
52
53
|
"liquidjs": "^10.21.1",
|
|
53
54
|
"nunjucks": "^3.2.4",
|
|
54
55
|
"pug": "^3.0.3",
|
|
55
56
|
"underscore": "^1.13.7",
|
|
56
|
-
"writr": "^4.4.
|
|
57
|
+
"writr": "^4.4.6"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
60
|
"@types/ejs": "^3.1.5",
|
|
60
|
-
"@types/node": "^24.0
|
|
61
|
+
"@types/node": "^24.3.0",
|
|
61
62
|
"@types/nunjucks": "^3.2.6",
|
|
62
63
|
"@types/pug": "^2.0.10",
|
|
63
64
|
"@types/underscore": "^1.13.0",
|
|
64
|
-
"@vitest/coverage-v8": "^3.2.
|
|
65
|
-
"docula": "^0.
|
|
65
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
66
|
+
"docula": "^0.20.0",
|
|
66
67
|
"rimraf": "^6.0.1",
|
|
67
68
|
"tsup": "^8.5.0",
|
|
68
|
-
"typescript": "^5.
|
|
69
|
-
"vitest": "^3.2.
|
|
70
|
-
"webpack": "^5.
|
|
71
|
-
"xo": "^1.
|
|
69
|
+
"typescript": "^5.9.2",
|
|
70
|
+
"vitest": "^3.2.4",
|
|
71
|
+
"webpack": "^5.101.3",
|
|
72
|
+
"xo": "^1.2.0"
|
|
72
73
|
},
|
|
73
74
|
"files": [
|
|
74
75
|
"dist",
|