2022-11-18 22:18:36 +01:00
2021-08-08 19:17:12 +02:00
2022-11-18 22:18:36 +01:00
2022-11-03 19:27:13 +01:00
2022-11-18 16:37:10 +01:00
2021-04-20 17:25:45 +02:00
2022-11-03 18:43:20 +00:00
2022-11-18 16:37:10 +01:00
2022-10-31 18:05:31 +01:00
2022-11-03 18:43:20 +00:00

JSSTE

npm NPM Downloads

NPM

Desciption

JSSTE is a NodeJS-Module for rendering data in static HTML

Usage

Installation

You can jsste install using npm or yarn.

npm install jsste
yarn add jsste

including in your project

const jsste = require("jsste");

Rendering

jsste.render(pagecode, tempaltecode);

Example

const templatecode = `
<html>
  <head>
    <title>JSSTE Example</title>
  </head>
  <body>
    <h1><[VARNAME1]></h1>
    <p><[VARNAME2]></p>
  </body>
</html>
`;

const pagecode = { VARNAME1: "Hello World", VARNAME2: "This is a test" };

let result = Jsste.render(pagecode, templatecode);

// result
// <html>
//   <head>
//     <title>JSSTE Example</title>
//   </head>
//   <body>
//     <h1>Hello World</h1>
//     <p>This is a test</p>
//   </body>
// </html>

Special Variables

  • _TEMPLATE_ -> Defines the path to the temp file
  • _STYLES_ -> Defines a list of CSS files that will be implemented

Include States

You can include an Callbackfunction that will be called when the state is change

jsste.setStateFunction(({ status, statusMSG }) => {
  yourstatus = status;
  yourstatusMSG = statusMSG;
});

States-Codes

Code Meaning
0 OK
1 ERROR
2 WARNING
3 INFO
4 DEBUG

Example

const templatecode = `
<html>
  <head>
    <title>JSSTE Example</title>
  </head>
  <body>
    <h1><[VARNAME1]></h1>
    <p><[VARNAME2]></p>
  </body>
</html>
`;

const pagecode = {"_STYLES_":["./main","./othercss"] "VARNAME1":"Hello World", "VARNAME2":"This is a test"};

let result = Jsste.render(pagecode, templatecode);

// result
// <html>
//   <head>
//     <title>JSSTE Example</title>
//     <link rel="stylesheet" href="./main.css">
//     <link rel="stylesheet" href="./othercss.css">
//   </head>
//   <body>
//     <h1>Hello World</h1>
//     <p>This is a test</p>
//   </body>
// </html>

Examples on https://github.com/lucaspalomodevelop/JSSTE-Examples

Description
No description provided
Readme GPL-3.0 404 KiB
Languages
JavaScript 100%