fixing rendering file wothout template-path

This commit is contained in:
lucaspalomodevelop 2022-11-25 20:10:30 +01:00
parent 99934228da
commit f97e535877

View File

@ -7,11 +7,11 @@ var app = {};
app.render = engine.render;
app.CONST = engine.CONST;
let pj = require("../package.json")
let pj = require("../package.json");
app.info = {};
app.info["version"] = pj.version
app.info["license"] = pj.license
app.info["version"] = pj.version;
app.info["license"] = pj.license;
/**
* Render File
* @param {*} filePath
@ -22,11 +22,16 @@ app.renderFile = (filePath, templatePath) => {
let file = fs.readFileSync(filePath, "utf8");
app.setState({ status: 0, statusMSG: "parse file" });
file = JSON.parse(file);
app.setState({ status: 0, statusMSG: "read template" });
let temp = fs.readFileSync(templatePath, "utf8");
app.setState({ status: 0, statusMSG: "set Selfpath" });
file["_SELFPATH_"] = path.dirname(filePath);
return engine.render(file,temp);
if (!(templatePath == undefined)) {
app.setState({ status: 0, statusMSG: "read template" });
let temp = fs.readFileSync(templatePath, "utf8");
return engine.render(file, temp);
} else {
return engine.render(file);
}
};
/**
@ -54,5 +59,4 @@ app.config = app.__config.getConfig();
engine.log = app.log;
engine.setState = app.setState;
module.exports = app;