giterman
v1.1.1
Published
Simple minimalistic HTML template engine
Downloads
2
Readme
Happy coding!
const renderHTML = require("giterman")
const finalHTML = renderHTML("./index.html", {firstName: "rani", lastName: "giterman"})
$ npm i giterman
The main function receives two paramaters. First one being pathFile
and second one being fields
.
<!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: