express helper that caches all .pug files to memory on startup
$ npm install --save express-pug-cache-helper
Below is a example of usage.
var express = require('express');
var pugCacheHelper = require('express-pug-cache-helper');
var app = express();
var indexApp = express();
indexApp.set('view engine', 'pug');
indexApp.set('views', __dirname + '/templates');
indexApp.get('/home', function(req, res, next){
res.render('show');
});
app.use(pugCacheHelper(adminApp), {force: true}); // <= important part
app.listen(3000);
pugCacheHelper(expressApp, options)
:
- expressApp: express app, important: it needs to fire
'mount'
event - options:
- force: Forces express
view cache
setting totrue
(defaultundefined
) - pugCompileOptions: Options object handed over to
pug.compileFile
(default{cache: true}
) - pugExt: Template file name extension (default
'.pug'
)
- force: Forces express
Use DEBUG=epch:cache
to debug with debug.