ecto 4.2.2 → 4.2.4
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/ecto.d.ts +4 -0
- package/dist/ecto.js +18 -14
- package/package.json +13 -24
package/dist/ecto.d.ts
CHANGED
|
@@ -99,6 +99,10 @@ declare class Ecto {
|
|
|
99
99
|
private readonly __nunjucks;
|
|
100
100
|
private readonly __handlebars;
|
|
101
101
|
private readonly __liquid;
|
|
102
|
+
/**
|
|
103
|
+
* Ecto constructor
|
|
104
|
+
* @param {EctoOptions} [options] - The options for the ecto engine
|
|
105
|
+
*/
|
|
102
106
|
constructor(options?: EctoOptions);
|
|
103
107
|
/**
|
|
104
108
|
* Get the default engine
|
package/dist/ecto.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/ecto.ts
|
|
2
|
-
import fs2 from "
|
|
2
|
+
import fs2 from "fs";
|
|
3
3
|
import { Writr as Writr2 } from "writr";
|
|
4
4
|
|
|
5
5
|
// src/engine-map.ts
|
|
@@ -101,7 +101,7 @@ var Markdown = class extends BaseEngine {
|
|
|
101
101
|
};
|
|
102
102
|
|
|
103
103
|
// src/engines/handlebars.ts
|
|
104
|
-
import fs from "
|
|
104
|
+
import fs from "fs";
|
|
105
105
|
import * as _ from "underscore";
|
|
106
106
|
import { helpers, handlebars } from "@jaredwray/fumanchu";
|
|
107
107
|
var Handlebars = class extends BaseEngine {
|
|
@@ -174,16 +174,16 @@ var EJS = class extends BaseEngine {
|
|
|
174
174
|
this.setExtensions(["ejs"]);
|
|
175
175
|
}
|
|
176
176
|
async render(source, data) {
|
|
177
|
-
this.engine
|
|
178
|
-
this.opts
|
|
177
|
+
this.engine ??= ejs;
|
|
178
|
+
this.opts ??= {};
|
|
179
179
|
if (this.rootTemplatePath) {
|
|
180
180
|
this.opts.root = this.rootTemplatePath;
|
|
181
181
|
}
|
|
182
182
|
return ejs.render(source, data, this.opts);
|
|
183
183
|
}
|
|
184
184
|
renderSync(source, data) {
|
|
185
|
-
this.engine
|
|
186
|
-
this.opts
|
|
185
|
+
this.engine ??= ejs;
|
|
186
|
+
this.opts ??= {};
|
|
187
187
|
if (this.rootTemplatePath) {
|
|
188
188
|
this.opts.root = this.rootTemplatePath;
|
|
189
189
|
}
|
|
@@ -205,7 +205,7 @@ var Pug = class extends BaseEngine {
|
|
|
205
205
|
}
|
|
206
206
|
async render(source, data) {
|
|
207
207
|
if (this.rootTemplatePath) {
|
|
208
|
-
this.opts
|
|
208
|
+
this.opts ??= {};
|
|
209
209
|
this.opts.basedir = this.rootTemplatePath;
|
|
210
210
|
}
|
|
211
211
|
const template = pug.compile(source, this.opts);
|
|
@@ -213,7 +213,7 @@ var Pug = class extends BaseEngine {
|
|
|
213
213
|
}
|
|
214
214
|
renderSync(source, data) {
|
|
215
215
|
if (this.rootTemplatePath) {
|
|
216
|
-
this.opts
|
|
216
|
+
this.opts ??= {};
|
|
217
217
|
this.opts.basedir = this.rootTemplatePath;
|
|
218
218
|
}
|
|
219
219
|
const template = pug.compile(source, this.opts);
|
|
@@ -240,7 +240,7 @@ var Nunjucks = class extends BaseEngine {
|
|
|
240
240
|
} else {
|
|
241
241
|
nunjucks.configure(this.opts);
|
|
242
242
|
}
|
|
243
|
-
data
|
|
243
|
+
data ??= {};
|
|
244
244
|
return nunjucks.renderString(source, data);
|
|
245
245
|
}
|
|
246
246
|
renderSync(source, data) {
|
|
@@ -249,7 +249,7 @@ var Nunjucks = class extends BaseEngine {
|
|
|
249
249
|
} else {
|
|
250
250
|
nunjucks.configure(this.opts);
|
|
251
251
|
}
|
|
252
|
-
data
|
|
252
|
+
data ??= {};
|
|
253
253
|
return nunjucks.renderString(source, data);
|
|
254
254
|
}
|
|
255
255
|
};
|
|
@@ -267,7 +267,7 @@ var Liquid = class extends BaseEngine {
|
|
|
267
267
|
}
|
|
268
268
|
async render(source, data) {
|
|
269
269
|
if (this.rootTemplatePath) {
|
|
270
|
-
this.opts
|
|
270
|
+
this.opts ??= {};
|
|
271
271
|
this.opts.root = this.rootTemplatePath;
|
|
272
272
|
}
|
|
273
273
|
if (!this.engine) {
|
|
@@ -277,7 +277,7 @@ var Liquid = class extends BaseEngine {
|
|
|
277
277
|
}
|
|
278
278
|
renderSync(source, data) {
|
|
279
279
|
if (this.rootTemplatePath) {
|
|
280
|
-
this.opts
|
|
280
|
+
this.opts ??= {};
|
|
281
281
|
this.opts.root = this.rootTemplatePath;
|
|
282
282
|
}
|
|
283
283
|
if (!this.engine) {
|
|
@@ -299,6 +299,10 @@ var Ecto = class {
|
|
|
299
299
|
__nunjucks;
|
|
300
300
|
__handlebars;
|
|
301
301
|
__liquid;
|
|
302
|
+
/**
|
|
303
|
+
* Ecto constructor
|
|
304
|
+
* @param {EctoOptions} [options] - The options for the ecto engine
|
|
305
|
+
*/
|
|
302
306
|
constructor(options) {
|
|
303
307
|
this.__ejs = new EJS(options?.engineOptions?.ejs);
|
|
304
308
|
this.__markdown = new Markdown(options?.engineOptions?.markdown);
|
|
@@ -434,7 +438,7 @@ var Ecto = class {
|
|
|
434
438
|
// eslint-disable-next-line max-params
|
|
435
439
|
async renderFromFile(filePath, data, rootTemplatePath, filePathOutput, engineName) {
|
|
436
440
|
let result = "";
|
|
437
|
-
engineName
|
|
441
|
+
engineName ??= this.getEngineByFilePath(filePath);
|
|
438
442
|
const source = await fs2.promises.readFile(filePath, "utf8");
|
|
439
443
|
result = await this.render(source, data, engineName, rootTemplatePath, filePathOutput);
|
|
440
444
|
return result;
|
|
@@ -451,7 +455,7 @@ var Ecto = class {
|
|
|
451
455
|
// eslint-disable-next-line max-params
|
|
452
456
|
renderFromFileSync(filePath, data, rootTemplatePath, filePathOutput, engineName) {
|
|
453
457
|
let result = "";
|
|
454
|
-
engineName
|
|
458
|
+
engineName ??= this.getEngineByFilePath(filePath);
|
|
455
459
|
const source = fs2.readFileSync(filePath, "utf8");
|
|
456
460
|
result = this.renderSync(source, data, engineName, rootTemplatePath, filePathOutput);
|
|
457
461
|
return result;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ecto",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.4",
|
|
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",
|
|
@@ -18,11 +18,10 @@
|
|
|
18
18
|
"author": "Jared Wray <me@jaredwray.com>",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"scripts": {
|
|
21
|
-
"watch": "tsc -w -p .",
|
|
22
21
|
"clean": "rimraf ./dist yarn.lock package-lock.json pnpm-lock.yaml ./coverage ./node_modules ./site/readme.md ./dist-site",
|
|
23
22
|
"test": "xo --fix && vitest run --coverage",
|
|
24
23
|
"build": "rimraf ./dist && tsup src/ecto.ts --format esm --dts --clean",
|
|
25
|
-
"prepare": "
|
|
24
|
+
"prepare": "pnpm build",
|
|
26
25
|
"website:build": "rimraf ./site/readme.md && npx -y docula build -s ./site -o ./dist-site",
|
|
27
26
|
"website:serve": "rimraf ./site/readme.md && npx -y docula serve -s ./site -o ./dist-site"
|
|
28
27
|
},
|
|
@@ -47,42 +46,32 @@
|
|
|
47
46
|
"liquidjs"
|
|
48
47
|
],
|
|
49
48
|
"dependencies": {
|
|
50
|
-
"@jaredwray/fumanchu": "^3.
|
|
49
|
+
"@jaredwray/fumanchu": "^3.1.1",
|
|
51
50
|
"ejs": "^3.1.10",
|
|
52
|
-
"liquidjs": "^10.21.
|
|
51
|
+
"liquidjs": "^10.21.1",
|
|
53
52
|
"nunjucks": "^3.2.4",
|
|
54
53
|
"pug": "^3.0.3",
|
|
55
54
|
"underscore": "^1.13.7",
|
|
56
|
-
"writr": "^4.4.
|
|
55
|
+
"writr": "^4.4.4"
|
|
57
56
|
},
|
|
58
57
|
"devDependencies": {
|
|
59
58
|
"@types/ejs": "^3.1.5",
|
|
60
|
-
"@types/node": "^22.
|
|
59
|
+
"@types/node": "^22.15.24",
|
|
61
60
|
"@types/nunjucks": "^3.2.6",
|
|
62
61
|
"@types/pug": "^2.0.10",
|
|
63
62
|
"@types/underscore": "^1.13.0",
|
|
64
|
-
"@vitest/coverage-v8": "^3.1.
|
|
65
|
-
"docula": "^0.
|
|
63
|
+
"@vitest/coverage-v8": "^3.1.4",
|
|
64
|
+
"docula": "^0.12.1",
|
|
66
65
|
"rimraf": "^6.0.1",
|
|
67
|
-
"tsup": "^8.
|
|
66
|
+
"tsup": "^8.5.0",
|
|
68
67
|
"typescript": "^5.8.3",
|
|
69
|
-
"vitest": "^3.1.
|
|
70
|
-
"webpack": "^5.99.
|
|
71
|
-
"xo": "^0.
|
|
72
|
-
},
|
|
73
|
-
"xo": {
|
|
74
|
-
"ignores": [
|
|
75
|
-
"vitest.config.mjs"
|
|
76
|
-
]
|
|
68
|
+
"vitest": "^3.1.4",
|
|
69
|
+
"webpack": "^5.99.9",
|
|
70
|
+
"xo": "^1.0.0"
|
|
77
71
|
},
|
|
78
72
|
"files": [
|
|
79
73
|
"dist",
|
|
80
74
|
"bin",
|
|
81
75
|
"LISCENSE"
|
|
82
|
-
]
|
|
83
|
-
"pnpm": {
|
|
84
|
-
"onlyBuiltDependencies": [
|
|
85
|
-
"esbuild"
|
|
86
|
-
]
|
|
87
|
-
}
|
|
76
|
+
]
|
|
88
77
|
}
|