express-pure-engine v1.5.0
express-pure-engine
pure-engine in express.
Table of Contents
Background
The library makes it easier to use pure-engine as a view engine in express. It handles file loading and caching out of the box. The engine is a compiler so the setup is slightly different from other templating engines, you probably want to provide few compiler options.
Install
npm install express-pure-engine
Usage
const path = require('path')
const express = require('express')
const createRender = require('express-pure-engine')
const app = require('app')
const render = createRender({
cacheEnabled: process.env.NODE_ENV === 'production',
compilerOptions: {
paths: [
path.join(__dirname, 'views'),
path.join(__dirname, 'public')
]
},
globals (path, options) {
return { foo: 'baz' }
}
})
app.set('views', path.join(__dirname, 'views'))
app.engine('html', render)
// other app code
API
cacheEnabled = true
It lets you disable cache in certain conditions. You probably don't want to cache files during development.
engine
You can override the engine, e.g. for additional statistics, logging, version update.
compilerOptions = {}
These options are passed down to pure-engine.
globals = {}
Often you have some data that can be reused in many pages. The option can be either a function that returns an object, or an object.
log = false
Option for displaying warnings and errors in console. By default logging is off.
Maintainers
Contributing
All contributions are highly appreciated! Open an issue or a submit PR.
License
MIT © buxlabs