ecto 4.8.7 → 5.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.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { Cacheable, CacheableMemory } from "cacheable";
2
2
  import { Hookified, HookifiedOptions } from "hookified";
3
-
4
3
  //#region src/engine-interface.d.ts
5
4
  type EngineInterface = {
6
5
  names: string[];
package/dist/ecto.mjs CHANGED
@@ -1,11 +1,10 @@
1
1
  import fs from "node:fs";
2
- import path from "node:path";
2
+ import nodePath from "node:path";
3
3
  import { Cacheable, CacheableMemory } from "cacheable";
4
4
  import { Hookified } from "hookified";
5
5
  import { Writr } from "writr";
6
6
  import ejs from "ejs";
7
7
  import { fumanchu } from "@jaredwray/fumanchu";
8
- import { decode } from "ent";
9
8
  import { Liquid as Liquid$1 } from "liquidjs";
10
9
  import * as nunjucks from "nunjucks";
11
10
  import * as pug from "pug";
@@ -110,15 +109,11 @@ var Handlebars = class extends BaseEngine {
110
109
  }
111
110
  async render(source, data) {
112
111
  if (this.rootTemplatePath) this.initPartials();
113
- let result = this.engine.compile(source, this.opts)(data, this.opts);
114
- result = decode(result);
115
- return result;
112
+ return this.engine.compile(source, this.opts)(data, this.opts);
116
113
  }
117
114
  renderSync(source, data) {
118
115
  if (this.rootTemplatePath) this.initPartials();
119
- let result = this.engine.compile(source, this.opts)(data, this.opts);
120
- result = decode(result);
121
- return result;
116
+ return this.engine.compile(source, this.opts)(data, this.opts);
122
117
  }
123
118
  initPartials() {
124
119
  for (const path of this.partialsPath) {
@@ -531,7 +526,7 @@ var Ecto = class extends Hookified {
531
526
  async renderFromFile(filePath, data, rootTemplatePath, filePathOutput, engineName) {
532
527
  let result = "";
533
528
  engineName ??= this.getEngineByFilePath(filePath);
534
- const templateRootPath = rootTemplatePath ?? path.dirname(filePath);
529
+ const templateRootPath = rootTemplatePath ?? nodePath.dirname(filePath);
535
530
  const source = await fs.promises.readFile(filePath, "utf8");
536
531
  result = await this.render(source, data, engineName, templateRootPath, filePathOutput);
537
532
  return result;
@@ -550,7 +545,7 @@ var Ecto = class extends Hookified {
550
545
  renderFromFileSync(filePath, data, rootTemplatePath, filePathOutput, engineName) {
551
546
  let result = "";
552
547
  engineName ??= this.getEngineByFilePath(filePath);
553
- const templateRootPath = rootTemplatePath ?? path.dirname(filePath);
548
+ const templateRootPath = rootTemplatePath ?? nodePath.dirname(filePath);
554
549
  const source = fs.readFileSync(filePath, "utf8");
555
550
  result = this.renderSync(source, data, engineName, templateRootPath, filePathOutput);
556
551
  return result;
@@ -563,10 +558,9 @@ var Ecto = class extends Hookified {
563
558
  * await ecto.ensureFilePath('/path/to/file.txt');
564
559
  */
565
560
  async ensureFilePath(path) {
566
- const pathList = path.split("/");
567
- pathList.pop();
568
- const directory = pathList.join("/");
569
- if (!fs.existsSync(directory)) fs.mkdirSync(directory, { recursive: true });
561
+ const normalizedPath = nodePath.normalize(path);
562
+ const directory = nodePath.dirname(normalizedPath);
563
+ await fs.promises.mkdir(directory, { recursive: true });
570
564
  }
571
565
  /**
572
566
  * Synchronously ensure that the directory path for a file exists, creating it if necessary
@@ -576,10 +570,9 @@ var Ecto = class extends Hookified {
576
570
  * ecto.ensureFilePathSync('/path/to/file.txt');
577
571
  */
578
572
  ensureFilePathSync(path) {
579
- const pathList = path.split("/");
580
- pathList.pop();
581
- const directory = pathList.join("/");
582
- if (!fs.existsSync(directory)) fs.mkdirSync(directory, { recursive: true });
573
+ const normalizedPath = nodePath.normalize(path);
574
+ const directory = nodePath.dirname(normalizedPath);
575
+ fs.mkdirSync(directory, { recursive: true });
583
576
  }
584
577
  /**
585
578
  * Determine the appropriate template engine based on a file's extension
@@ -591,7 +584,8 @@ var Ecto = class extends Hookified {
591
584
  getEngineByFilePath(filePath) {
592
585
  let result = this._defaultEngine;
593
586
  if (filePath !== void 0) {
594
- const extension = filePath.includes(".") ? filePath.slice(filePath.lastIndexOf(".") + 1) : "";
587
+ const { ext } = nodePath.parse(filePath);
588
+ const extension = ext.startsWith(".") ? ext.slice(1) : ext;
595
589
  const engExtension = this._mapping.getName(extension);
596
590
  if (engExtension !== void 0) result = engExtension;
597
591
  }
@@ -609,7 +603,7 @@ var Ecto = class extends Hookified {
609
603
  let result = "";
610
604
  const files = await fs.promises.readdir(path);
611
605
  for (const file of files) if (file.startsWith(`${templateName}.`)) {
612
- result = `${path}/${file}`;
606
+ result = nodePath.join(path, file);
613
607
  break;
614
608
  }
615
609
  return result;
@@ -626,7 +620,7 @@ var Ecto = class extends Hookified {
626
620
  let result = "";
627
621
  const files = fs.readdirSync(path);
628
622
  for (const file of files) if (file.startsWith(`${templateName}.`)) {
629
- result = `${path}/${file}`;
623
+ result = nodePath.join(path, file);
630
624
  break;
631
625
  }
632
626
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ecto",
3
- "version": "4.8.7",
3
+ "version": "5.1.0",
4
4
  "description": "Modern Template Consolidation Engine for EJS, Markdown, Pug, Nunjucks, Liquid, and Handlebars",
5
5
  "type": "module",
6
6
  "main": "./dist/ecto.mjs",
@@ -18,6 +18,9 @@
18
18
  },
19
19
  "author": "Jared Wray <me@jaredwray.com>",
20
20
  "license": "MIT",
21
+ "engines": {
22
+ "node": ">=22.18.0"
23
+ },
21
24
  "keywords": [
22
25
  "templates",
23
26
  "generator",
@@ -39,31 +42,30 @@
39
42
  "liquidjs"
40
43
  ],
41
44
  "dependencies": {
42
- "@jaredwray/fumanchu": "^4.7.0",
43
- "cacheable": "^2.3.5",
44
- "ejs": "^5.0.2",
45
- "ent": "^2.2.2",
46
- "hookified": "^2.2.0",
47
- "liquidjs": "^10.27.0",
45
+ "@jaredwray/fumanchu": "^4.7.2",
46
+ "cacheable": "^2.5.0",
47
+ "ejs": "^6.0.1",
48
+ "hookified": "^3.0.2",
49
+ "liquidjs": "^10.29.0",
48
50
  "nunjucks": "^3.2.4",
49
51
  "pug": "^3.0.4",
50
- "writr": "^6.1.2"
52
+ "writr": "^6.1.5"
51
53
  },
52
54
  "devDependencies": {
53
- "@biomejs/biome": "^2.4.15",
54
- "@faker-js/faker": "^10.4.0",
55
+ "@biomejs/biome": "^2.5.9",
56
+ "@faker-js/faker": "^10.6.0",
55
57
  "@types/ejs": "^3.1.5",
56
- "@types/ent": "^2.2.8",
57
- "@types/node": "^24.12.4",
58
+ "@types/node": "^24.13.3",
58
59
  "@types/nunjucks": "^3.2.6",
59
60
  "@types/pug": "^2.0.10",
60
- "@vitest/coverage-v8": "^4.1.7",
61
- "docula": "^2.0.0",
61
+ "@vitest/coverage-v8": "^4.1.11",
62
+ "docula": "^3.0.0",
62
63
  "rimraf": "^6.1.3",
63
- "tsdown": "^0.22.0",
64
- "typescript": "^6.0.3",
65
- "vite": "^8.0.14",
66
- "vitest": "^4.1.7"
64
+ "tsdown": "^0.22.14",
65
+ "typescript": "^7.0.2",
66
+ "vite": "^8.2.1",
67
+ "vitest": "^4.1.11",
68
+ "wrangler": "^4.124.0"
67
69
  },
68
70
  "files": [
69
71
  "dist",