This is a node.js template module. It's based on EJS, written in ES6 with simplicity in mind.
npm i keikan
First, assume we have a file named path/to/file.html
with the following contents:
<h3>
Hello
<strong><%= name %></strong>
</h3>
Then, you could compile and render this file with the following code:
import { Renderer } from "keikan"
const keikan = new Renderer({ debug : true });
const view = await keikan.compilePath("path/to/file");
console.log(view({ name: "Diogo" }));
The example will print:
<h3>
Hello
<strong>Diogo</strong>
</h3>
If debug
flag is disabled or not present, it would instead print:
<h3>Hello
<strong>Diogo</strong></h3>
It will try to remove spaces where it know they're not needed.
import * as Keikan from "keikan"
import express from "express"
const app = express();
app.engine("html", Keikan.renderPath);
app.set("view engine", "html");
// ...
import { Renderer } from "keikan"
// defaults
const keikan = new Renderer({
debug : false, // true/false
extension : "html", // will be appended to view names if name does not end with .html
resolver : Resolver("html"), // internal resolver (path, base_path)
});