keikan
v0.4.4
Published
Node template based on ejs
Downloads
139
Readme
Keikan (景観)
This is a node.js template module. It's based on EJS, written in ES6 with simplicity in mind.
Install
npm i keikan
Usage
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.
Express Usage
import * as Keikan from "keikan"
import express from "express"
const app = express();
app.engine("html", Keikan.renderPath);
app.set("view engine", "html");
// ...
Options
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)
});