ejs-render-middleware
v0.0.2
Published
Express-compatible EJS middleware that renders, caches result and watches for changes
Downloads
3
Readme
ejs-render-middleware
- Renders ejs file right away and puts result to
req.rendered
. - When in production, constantly caches contents of ejs file(s), else checks for changes and always rerenders fresh version of it
Installation
npm i -S ejs-render-middleware
Usage
const ejsRenderMiddleware = require('ejs-render-middleware')
app.use(ejsRenderMiddleware({
path: '/path/to.ejs',
data: {
title: 'Page title',
something: 'something'
},
options: { ... } // options for EJS compiler
}))
or pass it properties from req
or res
:
const ejsRenderMiddleware = require('ejs-render-middleware')
app.use(ejsRenderMiddleware((req, res) => ({
path: req.pathToEjs,
data: {
title: 'Page title',
something: req.something
},
options: { ... } // options for EJS compiler
})))