https://github.com/dresende/keikan
Node.js simple HTML templating similar to EJS
https://github.com/dresende/keikan
Last synced: 3 months ago
JSON representation
Node.js simple HTML templating similar to EJS
- Host: GitHub
- URL: https://github.com/dresende/keikan
- Owner: dresende
- License: mit
- Created: 2024-02-02T11:21:18.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-10-23T07:35:53.000Z (about 1 year ago)
- Last Synced: 2025-02-11T02:36:29.346Z (11 months ago)
- Language: JavaScript
- Size: 133 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## Keikan (景観)
[](https://npmjs.org/package/keikan)
[](mailto:dresende@thinkdigital.pt)


[](https://codecov.io/gh/dresende/keikan)
[](https://codeclimate.com/github/dresende/keikan/maintainability)
[](https://opensource.org/licenses/MIT)
This is a node.js template module. It's based on EJS, written in ES6 with
simplicity in mind.
### Install
```sh
npm i keikan
```
### Usage
First, assume we have a file named `path/to/file.html` with the following contents:
```html
Hello
<%= name %>
```
Then, you could compile and render this file with the following code:
```js
import { Renderer } from "keikan"
const keikan = new Renderer({ debug : true });
const view = await keikan.compilePath("path/to/file");
console.log(await view({ name: "Diogo" }));
```
The example will print:
```html
Hello
Diogo
```
If `debug` flag is disabled or not present, it would instead print:
```html
Hello
Diogo
```
It will try to remove spaces where it know they're not needed.
### Express Usage
```js
import * as Keikan from "keikan"
import express from "express"
const app = express();
app.engine("html", Keikan.renderPath);
app.set("view engine", "html");
// ...
```
### Options
```js
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)
});
```