mirror of
https://github.com/lucaspalomodevelop/JSSTE.git
synced 2026-03-16 16:44:36 +00:00
110 lines
2.0 KiB
Markdown
110 lines
2.0 KiB
Markdown
# JSSTE
|
|
|
|
<include>./blub.emd</include>
|
|
|
|

|
|

|
|
[](https://www.npmjs.com/package/jsste)
|
|
|
|
[](https://www.npmjs.com/package/jsste)
|
|
|
|
## Desciption
|
|
|
|
JSSTE is a NodeJS-Module for rendering data in static HTML
|
|
|
|
## Usage
|
|
|
|
### Installation
|
|
|
|
You can jsste install using [npm](https://www.npmjs.com/package/jsste) or [yarn](https://yarnpkg.com/package/jsste).
|
|
|
|
```sh
|
|
npm install jsste
|
|
```
|
|
|
|
```sh
|
|
yarn add jsste
|
|
```
|
|
|
|
#### including in your project
|
|
|
|
```javascript
|
|
const jsste = require("jsste");
|
|
```
|
|
|
|
### Rendering
|
|
|
|
```javascript
|
|
jsste.render(pagecode, tempaltecode);
|
|
```
|
|
|
|
#### Example
|
|
|
|
```javascript
|
|
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
|
|
|
|
#### Example
|
|
|
|
```javascript
|
|
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>
|
|
|
|
```
|