modify cmd | add templatefile to renderFile

This commit is contained in:
lucaspalomodevelop 2022-11-18 19:05:05 +01:00
parent 60e26ffb37
commit 1bddfdd4fd
2 changed files with 8 additions and 7 deletions

View File

@ -4,8 +4,6 @@ let output = "";
let pagefile, tempfile;
let fs = require("fs");
let addCommand = ({prefix,args = myargs}, callback) =>
{
myargs.forEach((elem) =>{
@ -28,14 +26,15 @@ addCommand({prefix:"-Jsconfig="},(arg) =>{
})
addCommand({prefix:"-page="},(arg) =>{
pagefile = JSON.parse(fs.readFileSync(arg,"utf-8").toString())
pagefile = arg
})
addCommand({prefix:"-temp="},(arg) =>{
tempfile = fs.readFileSync(arg, "utf-8").toString()
tempfile = arg
})
output = jsste.render(pagefile || undefined, tempfile || undefined)
output = jsste.renderFile(pagefile || undefined, tempfile || undefined)
addCommand({prefix:"-out"},(arg) =>{
console.log(output)

View File

@ -11,14 +11,16 @@ app.CONST = engine.CONST;
* @param {*} filePath
* @returns
*/
app.renderFile = (filePath) => {
app.renderFile = (filePath, templatePath) => {
app.setState({ status: 0, statusMSG: "read file" });
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);
return engine.render(file,temp);
};
/**