Table of contents
Edge
A template for Node.js
Edge is a logical and batteries included template engine for Node.js. It can render any text based format, whether is HTML, Markdown or plain text files.
Usage
Install the package from the npm registry.
npm i edge.js
yarn add edge.js
And use it as follows
const { join } = require('path')
const { Edge } = require('edge.js')
const edge = new Edge({ cache: false })
edge.mount(join(__dirname, 'views'))
const html = await edge.render('welcome', {
greeting: 'Hello world'
})
console.log(html)
Next create the views/welcome.edge
file.
<p> {{ greeting }} </p>
Edge was created to be used inside the AdonisJS framework. However it is a framework agnostic library and can be used standalone as well.
The documentation is written on the AdonisJS website. In AdonisJS docs, we refer the edge
variable as view
.