mirror of
https://github.com/lucaspalomodevelop/JSSTE.git
synced 2026-03-13 07:19:37 +00:00
modify cmd | add templatefile to renderFile
This commit is contained in:
parent
60e26ffb37
commit
1bddfdd4fd
@ -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)
|
||||
|
||||
@ -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);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user