Compare commits

..

No commits in common. "main" and "1.3.0" have entirely different histories.
main ... 1.3.0

3 changed files with 14 additions and 19 deletions

View File

@ -18,8 +18,7 @@ jobs:
- uses: actions/setup-node@v3 - uses: actions/setup-node@v3
with: with:
node-version: 16 node-version: 16
- run: npm ci # - run: npm ci
- run: npm install
- run: npm test - run: npm test
publish-npm: publish-npm:
@ -31,7 +30,7 @@ jobs:
with: with:
node-version: 16 node-version: 16
registry-url: https://registry.npmjs.org/ registry-url: https://registry.npmjs.org/
- run: npm ci # - run: npm ci
- run: npm publish - run: npm publish
env: env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}} NODE_AUTH_TOKEN: ${{secrets.npm_token}}

View File

@ -1,6 +1,6 @@
{ {
"name": "jsste", "name": "jsste",
"version": "1.3.3", "version": "1.2.3",
"description": "A Javascript Static Template Engine", "description": "A Javascript Static Template Engine",
"main": "src/index.js", "main": "src/index.js",
"directories": { "directories": {

View File

@ -7,36 +7,31 @@ var app = {};
app.render = engine.render; app.render = engine.render;
app.CONST = engine.CONST; app.CONST = engine.CONST;
let pj = require("../package.json"); let pj = require("../package.json")
app.info = {}; app.info = {};
app.info["version"] = pj.version; app.info["version"] = pj.version
app.info["license"] = pj.license; app.info["license"] = pj.license
/** /**
* Render File * Render File
* @param {*} filePath * @param {*} filePath
* @returns * @returns
*/ */
app.renderFile = (filePath, templatePath) => { app.renderFile = (filePath, templatePath) => {
app.setState({ status: 0, statusMSG: "read file" }); app.setState({ status: 0, statusMSG: "read file" });
let file = fs.readFileSync(filePath, "utf8"); let file = fs.readFileSync(filePath, "utf8");
app.setState({ status: 0, statusMSG: "parse file" }); app.setState({ status: 0, statusMSG: "parse file" });
file = JSON.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" }); app.setState({ status: 0, statusMSG: "set Selfpath" });
file["_SELFPATH_"] = path.dirname(filePath); 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);
}
}; };
/** /**
* set State * set State
* @param {*} param0 * @param {*} param0
*/ */
app.setState = ({ status, statusMSG }) => { app.setState = ({ status, statusMSG }) => {
if (app.stateCallback != undefined) { if (app.stateCallback != undefined) {
@ -46,7 +41,7 @@ app.setState = ({ status, statusMSG }) => {
/** /**
* Set function that would called by new state * Set function that would called by new state
* @param {*} callback * @param {*} callback
*/ */
app.setStateFunction = function (callback) { app.setStateFunction = function (callback) {
app.stateCallback = callback; app.stateCallback = callback;
@ -59,4 +54,5 @@ app.config = app.__config.getConfig();
engine.log = app.log; engine.log = app.log;
engine.setState = app.setState; engine.setState = app.setState;
module.exports = app; module.exports = app;