ecto 4.4.3 → 4.5.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 +17 -14
- package/package.json +2 -2
package/dist/ecto.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/ecto.ts
|
|
2
2
|
import fs2 from "fs";
|
|
3
|
+
import path from "path";
|
|
3
4
|
import { Cacheable, CacheableMemory } from "cacheable";
|
|
4
5
|
import { Hookified } from "hookified";
|
|
5
6
|
import { Writr as Writr2 } from "writr";
|
|
@@ -142,8 +143,8 @@ var Handlebars = class extends BaseEngine {
|
|
|
142
143
|
return result;
|
|
143
144
|
}
|
|
144
145
|
initPartials() {
|
|
145
|
-
for (const
|
|
146
|
-
const fullPath = `${this.rootTemplatePath}/${
|
|
146
|
+
for (const path2 of this.partialsPath) {
|
|
147
|
+
const fullPath = `${this.rootTemplatePath}/${path2}`;
|
|
147
148
|
this.registerPartials(fullPath);
|
|
148
149
|
}
|
|
149
150
|
}
|
|
@@ -547,12 +548,13 @@ var Ecto = class extends Hookified {
|
|
|
547
548
|
async renderFromFile(filePath, data, rootTemplatePath, filePathOutput, engineName) {
|
|
548
549
|
let result = "";
|
|
549
550
|
engineName ??= this.getEngineByFilePath(filePath);
|
|
551
|
+
const templateRootPath = rootTemplatePath ?? path.dirname(filePath);
|
|
550
552
|
const source = await fs2.promises.readFile(filePath, "utf8");
|
|
551
553
|
result = await this.render(
|
|
552
554
|
source,
|
|
553
555
|
data,
|
|
554
556
|
engineName,
|
|
555
|
-
|
|
557
|
+
templateRootPath,
|
|
556
558
|
filePathOutput
|
|
557
559
|
);
|
|
558
560
|
return result;
|
|
@@ -569,12 +571,13 @@ var Ecto = class extends Hookified {
|
|
|
569
571
|
renderFromFileSync(filePath, data, rootTemplatePath, filePathOutput, engineName) {
|
|
570
572
|
let result = "";
|
|
571
573
|
engineName ??= this.getEngineByFilePath(filePath);
|
|
574
|
+
const templateRootPath = rootTemplatePath ?? path.dirname(filePath);
|
|
572
575
|
const source = fs2.readFileSync(filePath, "utf8");
|
|
573
576
|
result = this.renderSync(
|
|
574
577
|
source,
|
|
575
578
|
data,
|
|
576
579
|
engineName,
|
|
577
|
-
|
|
580
|
+
templateRootPath,
|
|
578
581
|
filePathOutput
|
|
579
582
|
);
|
|
580
583
|
return result;
|
|
@@ -584,8 +587,8 @@ var Ecto = class extends Hookified {
|
|
|
584
587
|
* @param {string} path
|
|
585
588
|
* @returns {Promise<void>}
|
|
586
589
|
*/
|
|
587
|
-
async ensureFilePath(
|
|
588
|
-
const pathList =
|
|
590
|
+
async ensureFilePath(path2) {
|
|
591
|
+
const pathList = path2.split("/");
|
|
589
592
|
pathList.pop();
|
|
590
593
|
const directory = pathList.join("/");
|
|
591
594
|
if (!fs2.existsSync(directory)) {
|
|
@@ -597,8 +600,8 @@ var Ecto = class extends Hookified {
|
|
|
597
600
|
* @param {string} path
|
|
598
601
|
* @returns {void}
|
|
599
602
|
*/
|
|
600
|
-
ensureFilePathSync(
|
|
601
|
-
const pathList =
|
|
603
|
+
ensureFilePathSync(path2) {
|
|
604
|
+
const pathList = path2.split("/");
|
|
602
605
|
pathList.pop();
|
|
603
606
|
const directory = pathList.join("/");
|
|
604
607
|
if (!fs2.existsSync(directory)) {
|
|
@@ -627,12 +630,12 @@ var Ecto = class extends Hookified {
|
|
|
627
630
|
* @param {string} templateName
|
|
628
631
|
* @returns {Promise<string>} - the path to the template file
|
|
629
632
|
*/
|
|
630
|
-
async findTemplateWithoutExtension(
|
|
633
|
+
async findTemplateWithoutExtension(path2, templateName) {
|
|
631
634
|
let result = "";
|
|
632
|
-
const files = await fs2.promises.readdir(
|
|
635
|
+
const files = await fs2.promises.readdir(path2);
|
|
633
636
|
for (const file of files) {
|
|
634
637
|
if (file.startsWith(`${templateName}.`)) {
|
|
635
|
-
result = `${
|
|
638
|
+
result = `${path2}/${file}`;
|
|
636
639
|
break;
|
|
637
640
|
}
|
|
638
641
|
}
|
|
@@ -644,12 +647,12 @@ var Ecto = class extends Hookified {
|
|
|
644
647
|
* @param {string} templateName
|
|
645
648
|
* @returns {string} - the path to the template file
|
|
646
649
|
*/
|
|
647
|
-
findTemplateWithoutExtensionSync(
|
|
650
|
+
findTemplateWithoutExtensionSync(path2, templateName) {
|
|
648
651
|
let result = "";
|
|
649
|
-
const files = fs2.readdirSync(
|
|
652
|
+
const files = fs2.readdirSync(path2);
|
|
650
653
|
for (const file of files) {
|
|
651
654
|
if (file.startsWith(`${templateName}.`)) {
|
|
652
|
-
result = `${
|
|
655
|
+
result = `${path2}/${file}`;
|
|
653
656
|
break;
|
|
654
657
|
}
|
|
655
658
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ecto",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.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.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"liquidjs"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@jaredwray/fumanchu": "^4.0
|
|
52
|
+
"@jaredwray/fumanchu": "^4.1.0",
|
|
53
53
|
"cacheable": "^2.0.1",
|
|
54
54
|
"ejs": "^3.1.10",
|
|
55
55
|
"hookified": "^1.12.1",
|