mulmocast-vision 1.0.6 → 1.0.7
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/lib/html_class.d.ts +2 -0
- package/lib/html_class.js +13 -2
- package/package.json +1 -1
package/lib/html_class.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import nunjucks from "nunjucks";
|
|
1
2
|
import { type PluginOptionParams, type ToolArgs, type CreatePageOptions } from "./type";
|
|
2
3
|
export declare class htmlPlugin {
|
|
3
4
|
protected outputDir: string;
|
|
@@ -6,6 +7,7 @@ export declare class htmlPlugin {
|
|
|
6
7
|
protected templateDir: string;
|
|
7
8
|
protected sessionDir: string;
|
|
8
9
|
protected templateOptions: CreatePageOptions;
|
|
10
|
+
protected nunjucksEnv: nunjucks.Environment;
|
|
9
11
|
constructor({ outputDir, rootDir, templateOptions, htmlDir, // relative path
|
|
10
12
|
templateDir, }: {
|
|
11
13
|
outputDir?: string;
|
package/lib/html_class.js
CHANGED
|
@@ -77,10 +77,12 @@ class htmlPlugin {
|
|
|
77
77
|
logger.fileRead(templateFilePath);
|
|
78
78
|
logger.debug("Rendering template", { templateFileName, args });
|
|
79
79
|
try {
|
|
80
|
-
|
|
80
|
+
// Use the configured Nunjucks environment instead of the default
|
|
81
|
+
// This ensures the FileSystemLoader can find the template
|
|
82
|
+
return this.nunjucksEnv.render(`${templateFileName}.html`, args);
|
|
81
83
|
}
|
|
82
84
|
catch (error) {
|
|
83
|
-
logger.error("Template rendering failed", error, { templateFilePath, args });
|
|
85
|
+
logger.error("Template rendering failed", error, { templateFilePath, templateFileName, args });
|
|
84
86
|
throw error;
|
|
85
87
|
}
|
|
86
88
|
};
|
|
@@ -166,6 +168,15 @@ class htmlPlugin {
|
|
|
166
168
|
this.htmlDir = htmlDir ?? "html2";
|
|
167
169
|
this.templateDir = templateDir ?? "";
|
|
168
170
|
this.templateOptions = templateOptions ?? {};
|
|
171
|
+
// Configure Nunjucks environment with FileSystemLoader
|
|
172
|
+
const templatePath = this.templateDir ? this.templateDir : path_1.default.resolve(this.rootDir, "html", this.htmlDir);
|
|
173
|
+
const loader = new nunjucks_1.default.FileSystemLoader(templatePath, {
|
|
174
|
+
noCache: true, // Disable cache to ensure fresh templates
|
|
175
|
+
});
|
|
176
|
+
this.nunjucksEnv = new nunjucks_1.default.Environment(loader, {
|
|
177
|
+
autoescape: false, // Don't escape HTML
|
|
178
|
+
throwOnUndefined: false, // Don't throw on undefined variables
|
|
179
|
+
});
|
|
169
180
|
}
|
|
170
181
|
}
|
|
171
182
|
exports.htmlPlugin = htmlPlugin;
|