1.1.1 • Published 2 years ago

giterman v1.1.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

const finalHTML = renderHTML("./index.html", {firstName: "rani", lastName: "giterman"})

</p>

<h1>
  🤍 Installation 🤍
</h1>
<p style="color: yellow;">

$ npm i giterman

</p>

<h1>
 ❔ <b>Documentation</b> ❔
</h1>

<p>
You can call the main function with whatever name you'd like. As long as you install the package and require it in your code. <br>

The main function receives two paramaters. First one being `pathFile` and second one being `fields`.

- <h3>pathFile</h3> - The path to the HTML file.
- <h3>fields</h3> - An object documenting the text being replaced inside the HTML file. Each key stands for the field's name inside the HTML, 
    and it's value is the text which the HTML will be replaced with.
</p>

<h1>Example</h1>
<p>
Example HTML file (index.html):

```html
  <!DOCTYPE html>
  <html lang="en">
    <head>
      <meta charset="UTF-8" />
      <meta http-equiv="X-UA-Compatible" content="IE=edge" />
      <meta name="viewport" content="width=device-width, initial-scale=1.0" />
      <title>Title</title>
    </head>
    <body>
      <div>{{firstName}} {{lastName}}</div>
    </body>
  </html>

Example node.js express route which will send the HTML:

const express = require("express");
const PORT = 3000
const app = express();

const http = require("http").Server(app);

const renderHTML = require("giterman");

const finalHTML = renderHTML("./index.html", {
  firstName: "rani",
  lastName: "giterman",
});

app.get("/", (req, res) => {
  res.send(finalHTML);
});

http.listen(PORT, () => {
  console.log(`Server listening on ${PORT}`);
});

The result is the following: res

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago