ecto 3.0.8 → 4.1.0

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.js CHANGED
@@ -1,242 +1,506 @@
1
- import fs from 'node:fs';
2
- import { EngineMap } from './engine-map.js';
3
- import { Markdown } from './engines/markdown.js';
4
- import { Handlebars } from './engines/handlebars.js';
5
- import { EJS } from './engines/ejs.js';
6
- import { Pug } from './engines/pug.js';
7
- import { Nunjucks } from './engines/nunjucks.js';
8
- import { Liquid } from './engines/liquid.js';
9
- export class Ecto {
10
- __mapping = new EngineMap();
11
- __engines = new Array();
12
- __defaultEngine = 'ejs';
13
- // Engines
14
- __ejs;
15
- __markdown;
16
- __pug;
17
- __nunjucks;
18
- __handlebars;
19
- __liquid;
20
- constructor(options) {
21
- const engineOptions = { ...options };
22
- delete engineOptions.defaultEngine;
23
- // Engines
24
- this.__ejs = new EJS(engineOptions);
25
- this.__markdown = new Markdown(engineOptions);
26
- this.__pug = new Pug(engineOptions);
27
- this.__nunjucks = new Nunjucks(engineOptions);
28
- this.__handlebars = new Handlebars(engineOptions);
29
- this.__liquid = new Liquid(engineOptions);
30
- // Register engines
31
- this.__engines.push(this.__ejs, this.__markdown, this.__pug, this.__nunjucks, this.__handlebars, this.__liquid);
32
- // Register mappings
33
- this.registerEngineMappings();
34
- // Set the options
35
- if (options !== undefined && this.isValidEngine(options.defaultEngine)) {
36
- this.__defaultEngine = options.defaultEngine;
1
+ // src/ecto.ts
2
+ import fs2 from "node:fs";
3
+
4
+ // src/engine-map.ts
5
+ var EngineMap = class {
6
+ _mappings = /* @__PURE__ */ new Map();
7
+ set(name, extensions) {
8
+ const engineName = name.trim().toLowerCase();
9
+ const engineExtensions = new Array();
10
+ if (extensions.length > 0 && name !== "") {
11
+ for (let extension of extensions) {
12
+ extension = extension.trim().toLowerCase();
13
+ if (!engineExtensions.includes(extension)) {
14
+ engineExtensions.push(extension);
37
15
  }
16
+ }
17
+ this._mappings.set(engineName, engineExtensions);
38
18
  }
39
- get defaultEngine() {
40
- return this.__defaultEngine;
41
- }
42
- set defaultEngine(value) {
43
- value = value.toLowerCase().trim();
44
- if (this.isValidEngine(value)) {
45
- this.__defaultEngine = value;
19
+ }
20
+ delete(name) {
21
+ this._mappings.delete(name.trim().toLowerCase());
22
+ }
23
+ deleteExtension(name, extension) {
24
+ const engineName = name.trim().toLowerCase();
25
+ const extensions = this._mappings.get(engineName);
26
+ if (extensions) {
27
+ const engineExtensions = new Array();
28
+ for (const extension_ of extensions) {
29
+ if (extension_ !== extension.trim().toLowerCase()) {
30
+ engineExtensions.push(extension_);
46
31
  }
32
+ }
33
+ this._mappings.set(engineName, engineExtensions);
47
34
  }
48
- get mappings() {
49
- return this.__mapping;
35
+ }
36
+ get(name) {
37
+ return this._mappings.get(name.trim().toLowerCase());
38
+ }
39
+ getName(extension) {
40
+ let engineName;
41
+ for (const [name, extensions] of this._mappings) {
42
+ if (extensions.includes(extension.trim().toLowerCase())) {
43
+ engineName = name;
44
+ }
50
45
  }
51
- // Engines
52
- get ejs() {
53
- return this.__ejs;
46
+ return engineName;
47
+ }
48
+ };
49
+
50
+ // src/engines/markdown.ts
51
+ import { Writr } from "writr";
52
+
53
+ // src/base-engine.ts
54
+ var BaseEngine = class {
55
+ names = new Array();
56
+ opts = void 0;
57
+ engine;
58
+ rootTemplatePath = void 0;
59
+ __extensions = new Array();
60
+ getExtensions() {
61
+ return this.__extensions;
62
+ }
63
+ setExtensions(extensions) {
64
+ this.__extensions = new Array();
65
+ for (const extension of extensions) {
66
+ const newExtension = extension.trim().toLowerCase();
67
+ if (!this.__extensions.includes(newExtension)) {
68
+ this.__extensions.push(newExtension);
69
+ }
54
70
  }
55
- get markdown() {
56
- return this.__markdown;
71
+ }
72
+ deleteExtension(name) {
73
+ for (const [index, extension] of this.__extensions.entries()) {
74
+ if (name.toLowerCase().trim() === extension) {
75
+ this.__extensions.splice(index, 1);
76
+ }
57
77
  }
58
- get pug() {
59
- return this.__pug;
78
+ }
79
+ };
80
+
81
+ // src/engines/markdown.ts
82
+ var Markdown = class extends BaseEngine {
83
+ constructor(options) {
84
+ super();
85
+ this.names = ["markdown"];
86
+ if (options) {
87
+ this.opts = options;
60
88
  }
61
- get nunjucks() {
62
- return this.__nunjucks;
89
+ this.engine = new Writr(options);
90
+ this.setExtensions(["md", "markdown"]);
91
+ }
92
+ async render(source, data) {
93
+ this.engine.content = source;
94
+ return this.engine.render(data);
95
+ }
96
+ renderSync(source, data) {
97
+ this.engine.content = source;
98
+ return this.engine.renderSync(data);
99
+ }
100
+ };
101
+
102
+ // src/engines/handlebars.ts
103
+ import fs from "node:fs";
104
+ import * as _ from "underscore";
105
+ import fumanchu from "@jaredwray/fumanchu";
106
+ var Handlebars = class extends BaseEngine {
107
+ partialsPath = ["partials", "includes", "templates"];
108
+ constructor(options) {
109
+ super();
110
+ this.names = ["handlebars", "mustache"];
111
+ this.opts = options;
112
+ this.engine = fumanchu;
113
+ this.setExtensions(["hbs", "hjs", "handlebars", "mustache"]);
114
+ }
115
+ async render(source, data) {
116
+ if (this.rootTemplatePath) {
117
+ this.initPartials();
63
118
  }
64
- get handlebars() {
65
- return this.__handlebars;
119
+ const template = this.engine.compile(source, this.opts);
120
+ let result = template(data, this.opts);
121
+ result = _.unescape(result);
122
+ return result;
123
+ }
124
+ renderSync(source, data) {
125
+ if (this.rootTemplatePath) {
126
+ this.initPartials();
66
127
  }
67
- get liquid() {
68
- return this.__liquid;
128
+ const template = this.engine.compile(source, this.opts);
129
+ let result = template(data, this.opts);
130
+ result = _.unescape(result);
131
+ return result;
132
+ }
133
+ initPartials() {
134
+ for (const path of this.partialsPath) {
135
+ const fullPath = `${this.rootTemplatePath}/${path}`;
136
+ this.registerPartials(fullPath);
69
137
  }
70
- // String Render
71
- // eslint-disable-next-line max-params
72
- async render(source, data, engineName, rootTemplatePath, filePathOutput) {
73
- let result = '';
74
- let renderEngineName = this.__defaultEngine;
75
- // Set the render engine
76
- if (this.isValidEngine(engineName) && engineName !== undefined) {
77
- renderEngineName = engineName;
78
- }
79
- // Get the render engine
80
- const renderEngine = this.getRenderEngine(renderEngineName);
81
- // Set the root template path
82
- renderEngine.rootTemplatePath = rootTemplatePath;
83
- // Get the output
84
- result = await renderEngine.render(source, data);
85
- // Write out the file
86
- await this.writeFile(filePathOutput, result);
87
- return result;
88
- }
89
- // Render Sync
90
- // eslint-disable-next-line max-params
91
- renderSync(source, data, engineName, rootTemplatePath, filePathOutput) {
92
- let result = '';
93
- let renderEngineName = this.__defaultEngine;
94
- // Set the render engine
95
- if (this.isValidEngine(engineName) && engineName !== undefined) {
96
- renderEngineName = engineName;
97
- }
98
- // Get the render engine
99
- const renderEngine = this.getRenderEngine(renderEngineName);
100
- // Set the root template path
101
- renderEngine.rootTemplatePath = rootTemplatePath;
102
- // Get the output
103
- result = renderEngine.renderSync(source, data);
104
- // Write out the file
105
- this.writeFileSync(filePathOutput, result);
106
- return result;
107
- }
108
- // Render from File
109
- // eslint-disable-next-line max-params
110
- async renderFromFile(filePath, data, rootTemplatePath, filePathOutput, engineName) {
111
- let result = '';
112
- // Select which engine
113
- engineName ||= this.getEngineByFilePath(filePath);
114
- // Get the source
115
- const source = await fs.promises.readFile(filePath, 'utf8');
116
- result = await this.render(source, data, engineName, rootTemplatePath, filePathOutput);
117
- return result;
118
- }
119
- // Render from File Sync
120
- // eslint-disable-next-line max-params
121
- renderFromFileSync(filePath, data, rootTemplatePath, filePathOutput, engineName) {
122
- let result = '';
123
- // Select which engine
124
- engineName ||= this.getEngineByFilePath(filePath);
125
- // Get the source
126
- const source = fs.readFileSync(filePath, 'utf8');
127
- result = this.renderSync(source, data, engineName, rootTemplatePath, filePathOutput);
128
- return result;
129
- }
130
- async ensureFilePath(path) {
131
- const pathList = path.split('/');
132
- pathList.pop();
133
- const directory = pathList.join('/');
134
- if (!fs.existsSync(directory)) {
135
- fs.mkdirSync(directory, { recursive: true });
138
+ }
139
+ registerPartials(partialsPath) {
140
+ let result = false;
141
+ if (fs.existsSync(partialsPath)) {
142
+ const partials = fs.readdirSync(partialsPath, { recursive: true, encoding: "utf8" });
143
+ for (const p of partials) {
144
+ if (fs.statSync(partialsPath + "/" + p).isDirectory()) {
145
+ const directoryPartials = fs.readdirSync(partialsPath + "/" + p, { recursive: true, encoding: "utf8" });
146
+ for (const dp of directoryPartials) {
147
+ const source = fs.readFileSync(partialsPath + "/" + p + "/" + dp).toString();
148
+ const name = p + "/" + dp.split(".")[0];
149
+ this.engine.registerPartial(name, this.engine.compile(source));
150
+ }
151
+ } else {
152
+ const source = fs.readFileSync(partialsPath + "/" + p, "utf8");
153
+ const name = p.split(".")[0];
154
+ this.engine.registerPartial(name, this.engine.compile(source));
136
155
  }
156
+ }
157
+ result = true;
137
158
  }
138
- ensureFilePathSync(path) {
139
- const pathList = path.split('/');
140
- pathList.pop();
141
- const directory = pathList.join('/');
142
- if (!fs.existsSync(directory)) {
143
- fs.mkdirSync(directory, { recursive: true });
144
- }
159
+ return result;
160
+ }
161
+ };
162
+
163
+ // src/engines/ejs.ts
164
+ import * as ejs from "ejs";
165
+ var EJS = class extends BaseEngine {
166
+ constructor(options) {
167
+ super();
168
+ this.names = ["ejs"];
169
+ if (options) {
170
+ this.opts = options;
145
171
  }
146
- getEngineByFilePath(filePath) {
147
- let result = this.__defaultEngine;
148
- if (filePath !== undefined) {
149
- const extension = filePath.includes('.') ? filePath.slice(filePath.lastIndexOf('.') + 1) : '';
150
- const engExtension = this.__mapping.getName(extension);
151
- if (engExtension !== undefined) {
152
- result = engExtension;
153
- }
154
- }
155
- return result;
156
- }
157
- async findTemplateWithoutExtension(path, templateName) {
158
- let result = '';
159
- const files = await fs.promises.readdir(path);
160
- for (const file of files) {
161
- if (file.startsWith(templateName + '.')) {
162
- result = path + '/' + file;
163
- break;
164
- }
165
- }
166
- return result;
167
- }
168
- findTemplateWithoutExtensionSync(path, templateName) {
169
- let result = '';
170
- const files = fs.readdirSync(path);
171
- for (const file of files) {
172
- if (file.startsWith(templateName + '.')) {
173
- result = path + '/' + file;
174
- break;
175
- }
176
- }
177
- return result;
172
+ this.setExtensions(["ejs"]);
173
+ }
174
+ async render(source, data) {
175
+ this.engine ||= ejs;
176
+ this.opts ||= {};
177
+ if (this.rootTemplatePath) {
178
+ this.opts.root = this.rootTemplatePath;
178
179
  }
179
- // Engines
180
- isValidEngine(engineName) {
181
- let result = false;
182
- if (engineName !== undefined && this.__mapping.get(engineName) !== undefined) {
183
- result = true;
184
- }
185
- return result;
180
+ return ejs.render(source, data, this.opts);
181
+ }
182
+ renderSync(source, data) {
183
+ this.engine ||= ejs;
184
+ this.opts ||= {};
185
+ if (this.rootTemplatePath) {
186
+ this.opts.root = this.rootTemplatePath;
186
187
  }
187
- registerEngineMappings() {
188
- for (const eng of this.__engines) {
189
- for (const name of eng.names) {
190
- this.__mapping.set(name, eng.getExtensions());
191
- }
192
- }
188
+ return ejs.render(source, data, this.opts);
189
+ }
190
+ };
191
+
192
+ // src/engines/pug.ts
193
+ import * as pug from "pug";
194
+ var Pug = class extends BaseEngine {
195
+ constructor(options) {
196
+ super();
197
+ this.names = ["pug"];
198
+ this.engine = pug;
199
+ if (options) {
200
+ this.opts = options;
193
201
  }
194
- getRenderEngine(engineName) {
195
- let result = this.__ejs; // Setting default
196
- const cleanEngineName = engineName.trim().toLowerCase();
197
- switch (cleanEngineName) {
198
- case 'markdown': {
199
- result = this.__markdown;
200
- break;
201
- }
202
- case 'pug': {
203
- result = this.__pug;
204
- break;
205
- }
206
- case 'nunjucks': {
207
- result = this.__nunjucks;
208
- break;
209
- }
210
- case 'mustache': {
211
- result = this.__handlebars;
212
- break;
213
- }
214
- case 'handlebars': {
215
- result = this.__handlebars;
216
- break;
217
- }
218
- case 'liquid': {
219
- result = this.__liquid;
220
- break;
221
- }
222
- default: {
223
- result = this.__ejs;
224
- break;
225
- }
226
- }
227
- return result;
202
+ this.setExtensions(["pug", "jade"]);
203
+ }
204
+ async render(source, data) {
205
+ if (this.rootTemplatePath) {
206
+ this.opts ||= {};
207
+ this.opts.basedir = this.rootTemplatePath;
228
208
  }
229
- async writeFile(filePath, source) {
230
- if (filePath && source) {
231
- await this.ensureFilePath(filePath);
232
- await fs.promises.writeFile(filePath, source);
233
- }
209
+ const template = pug.compile(source, this.opts);
210
+ return template(data);
211
+ }
212
+ renderSync(source, data) {
213
+ if (this.rootTemplatePath) {
214
+ this.opts ||= {};
215
+ this.opts.basedir = this.rootTemplatePath;
234
216
  }
235
- writeFileSync(filePath, source) {
236
- if (filePath && source) {
237
- this.ensureFilePathSync(filePath);
238
- fs.writeFileSync(filePath, source);
239
- }
217
+ const template = pug.compile(source, this.opts);
218
+ return template(data);
219
+ }
220
+ };
221
+
222
+ // src/engines/nunjucks.ts
223
+ import * as nunjucks from "nunjucks";
224
+ var Nunjucks = class extends BaseEngine {
225
+ constructor(options) {
226
+ super();
227
+ this.names = ["nunjucks"];
228
+ this.engine = nunjucks;
229
+ this.opts = { autoescape: true };
230
+ if (options) {
231
+ this.opts = options;
232
+ }
233
+ this.setExtensions(["njk"]);
234
+ }
235
+ async render(source, data) {
236
+ if (this.rootTemplatePath) {
237
+ nunjucks.configure(this.rootTemplatePath, this.opts);
238
+ } else {
239
+ nunjucks.configure(this.opts);
240
+ }
241
+ data ||= {};
242
+ return nunjucks.renderString(source, data);
243
+ }
244
+ renderSync(source, data) {
245
+ if (this.rootTemplatePath) {
246
+ nunjucks.configure(this.rootTemplatePath, this.opts);
247
+ } else {
248
+ nunjucks.configure(this.opts);
249
+ }
250
+ data ||= {};
251
+ return nunjucks.renderString(source, data);
252
+ }
253
+ };
254
+
255
+ // src/engines/liquid.ts
256
+ import { Liquid as LiquidEngine } from "liquidjs";
257
+ var Liquid = class extends BaseEngine {
258
+ constructor(options) {
259
+ super();
260
+ this.names = ["liquid"];
261
+ if (options) {
262
+ this.opts = options;
263
+ }
264
+ this.setExtensions(["liquid"]);
265
+ }
266
+ async render(source, data) {
267
+ if (this.rootTemplatePath) {
268
+ this.opts ||= {};
269
+ this.opts.root = this.rootTemplatePath;
270
+ }
271
+ if (!this.engine) {
272
+ this.engine = new LiquidEngine(this.opts);
273
+ }
274
+ return this.engine.parseAndRender(source, data);
275
+ }
276
+ renderSync(source, data) {
277
+ if (this.rootTemplatePath) {
278
+ this.opts ||= {};
279
+ this.opts.root = this.rootTemplatePath;
280
+ }
281
+ if (!this.engine) {
282
+ this.engine = new LiquidEngine(this.opts);
283
+ }
284
+ return this.engine.parseAndRenderSync(source, data);
285
+ }
286
+ };
287
+
288
+ // src/ecto.ts
289
+ var Ecto = class {
290
+ __mapping = new EngineMap();
291
+ __engines = new Array();
292
+ __defaultEngine = "ejs";
293
+ // Engines
294
+ __ejs;
295
+ __markdown;
296
+ __pug;
297
+ __nunjucks;
298
+ __handlebars;
299
+ __liquid;
300
+ constructor(options) {
301
+ const engineOptions = { ...options };
302
+ delete engineOptions.defaultEngine;
303
+ this.__ejs = new EJS(engineOptions);
304
+ this.__markdown = new Markdown(engineOptions);
305
+ this.__pug = new Pug(engineOptions);
306
+ this.__nunjucks = new Nunjucks(engineOptions);
307
+ this.__handlebars = new Handlebars(engineOptions);
308
+ this.__liquid = new Liquid(engineOptions);
309
+ this.__engines.push(this.__ejs, this.__markdown, this.__pug, this.__nunjucks, this.__handlebars, this.__liquid);
310
+ this.registerEngineMappings();
311
+ if (options !== void 0 && this.isValidEngine(options.defaultEngine)) {
312
+ this.__defaultEngine = options.defaultEngine;
313
+ }
314
+ }
315
+ get defaultEngine() {
316
+ return this.__defaultEngine;
317
+ }
318
+ set defaultEngine(value) {
319
+ value = value.toLowerCase().trim();
320
+ if (this.isValidEngine(value)) {
321
+ this.__defaultEngine = value;
322
+ }
323
+ }
324
+ get mappings() {
325
+ return this.__mapping;
326
+ }
327
+ // Engines
328
+ get ejs() {
329
+ return this.__ejs;
330
+ }
331
+ get markdown() {
332
+ return this.__markdown;
333
+ }
334
+ get pug() {
335
+ return this.__pug;
336
+ }
337
+ get nunjucks() {
338
+ return this.__nunjucks;
339
+ }
340
+ get handlebars() {
341
+ return this.__handlebars;
342
+ }
343
+ get liquid() {
344
+ return this.__liquid;
345
+ }
346
+ // String Render
347
+ // eslint-disable-next-line max-params
348
+ async render(source, data, engineName, rootTemplatePath, filePathOutput) {
349
+ let result = "";
350
+ let renderEngineName = this.__defaultEngine;
351
+ if (this.isValidEngine(engineName) && engineName !== void 0) {
352
+ renderEngineName = engineName;
353
+ }
354
+ const renderEngine = this.getRenderEngine(renderEngineName);
355
+ renderEngine.rootTemplatePath = rootTemplatePath;
356
+ result = await renderEngine.render(source, data);
357
+ await this.writeFile(filePathOutput, result);
358
+ return result;
359
+ }
360
+ // Render Sync
361
+ // eslint-disable-next-line max-params
362
+ renderSync(source, data, engineName, rootTemplatePath, filePathOutput) {
363
+ let result = "";
364
+ let renderEngineName = this.__defaultEngine;
365
+ if (this.isValidEngine(engineName) && engineName !== void 0) {
366
+ renderEngineName = engineName;
367
+ }
368
+ const renderEngine = this.getRenderEngine(renderEngineName);
369
+ renderEngine.rootTemplatePath = rootTemplatePath;
370
+ result = renderEngine.renderSync(source, data);
371
+ this.writeFileSync(filePathOutput, result);
372
+ return result;
373
+ }
374
+ // Render from File
375
+ // eslint-disable-next-line max-params
376
+ async renderFromFile(filePath, data, rootTemplatePath, filePathOutput, engineName) {
377
+ let result = "";
378
+ engineName ||= this.getEngineByFilePath(filePath);
379
+ const source = await fs2.promises.readFile(filePath, "utf8");
380
+ result = await this.render(source, data, engineName, rootTemplatePath, filePathOutput);
381
+ return result;
382
+ }
383
+ // Render from File Sync
384
+ // eslint-disable-next-line max-params
385
+ renderFromFileSync(filePath, data, rootTemplatePath, filePathOutput, engineName) {
386
+ let result = "";
387
+ engineName ||= this.getEngineByFilePath(filePath);
388
+ const source = fs2.readFileSync(filePath, "utf8");
389
+ result = this.renderSync(source, data, engineName, rootTemplatePath, filePathOutput);
390
+ return result;
391
+ }
392
+ async ensureFilePath(path) {
393
+ const pathList = path.split("/");
394
+ pathList.pop();
395
+ const directory = pathList.join("/");
396
+ if (!fs2.existsSync(directory)) {
397
+ fs2.mkdirSync(directory, { recursive: true });
398
+ }
399
+ }
400
+ ensureFilePathSync(path) {
401
+ const pathList = path.split("/");
402
+ pathList.pop();
403
+ const directory = pathList.join("/");
404
+ if (!fs2.existsSync(directory)) {
405
+ fs2.mkdirSync(directory, { recursive: true });
406
+ }
407
+ }
408
+ getEngineByFilePath(filePath) {
409
+ let result = this.__defaultEngine;
410
+ if (filePath !== void 0) {
411
+ const extension = filePath.includes(".") ? filePath.slice(filePath.lastIndexOf(".") + 1) : "";
412
+ const engExtension = this.__mapping.getName(extension);
413
+ if (engExtension !== void 0) {
414
+ result = engExtension;
415
+ }
416
+ }
417
+ return result;
418
+ }
419
+ async findTemplateWithoutExtension(path, templateName) {
420
+ let result = "";
421
+ const files = await fs2.promises.readdir(path);
422
+ for (const file of files) {
423
+ if (file.startsWith(templateName + ".")) {
424
+ result = path + "/" + file;
425
+ break;
426
+ }
427
+ }
428
+ return result;
429
+ }
430
+ findTemplateWithoutExtensionSync(path, templateName) {
431
+ let result = "";
432
+ const files = fs2.readdirSync(path);
433
+ for (const file of files) {
434
+ if (file.startsWith(templateName + ".")) {
435
+ result = path + "/" + file;
436
+ break;
437
+ }
438
+ }
439
+ return result;
440
+ }
441
+ // Engines
442
+ isValidEngine(engineName) {
443
+ let result = false;
444
+ if (engineName !== void 0 && this.__mapping.get(engineName) !== void 0) {
445
+ result = true;
446
+ }
447
+ return result;
448
+ }
449
+ registerEngineMappings() {
450
+ for (const eng of this.__engines) {
451
+ for (const name of eng.names) {
452
+ this.__mapping.set(name, eng.getExtensions());
453
+ }
454
+ }
455
+ }
456
+ getRenderEngine(engineName) {
457
+ let result = this.__ejs;
458
+ const cleanEngineName = engineName.trim().toLowerCase();
459
+ switch (cleanEngineName) {
460
+ case "markdown": {
461
+ result = this.__markdown;
462
+ break;
463
+ }
464
+ case "pug": {
465
+ result = this.__pug;
466
+ break;
467
+ }
468
+ case "nunjucks": {
469
+ result = this.__nunjucks;
470
+ break;
471
+ }
472
+ case "mustache": {
473
+ result = this.__handlebars;
474
+ break;
475
+ }
476
+ case "handlebars": {
477
+ result = this.__handlebars;
478
+ break;
479
+ }
480
+ case "liquid": {
481
+ result = this.__liquid;
482
+ break;
483
+ }
484
+ default: {
485
+ result = this.__ejs;
486
+ break;
487
+ }
488
+ }
489
+ return result;
490
+ }
491
+ async writeFile(filePath, source) {
492
+ if (filePath && source) {
493
+ await this.ensureFilePath(filePath);
494
+ await fs2.promises.writeFile(filePath, source);
495
+ }
496
+ }
497
+ writeFileSync(filePath, source) {
498
+ if (filePath && source) {
499
+ this.ensureFilePathSync(filePath);
500
+ fs2.writeFileSync(filePath, source);
240
501
  }
241
- }
242
- //# sourceMappingURL=ecto.js.map
502
+ }
503
+ };
504
+ export {
505
+ Ecto
506
+ };