Skip to content

Express-compatible EJS middleware that renders, caches result and watches for changes

Notifications You must be signed in to change notification settings

ilearnio/ejs-render-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ejs-render-middleware

  1. Renders ejs file right away and puts result to req.rendered.
  2. 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
})))

About

Express-compatible EJS middleware that renders, caches result and watches for changes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages