express-pug-cache-helper

2.1.1 • Public • Published

express-pug-cache-helper

npm version Build Status codecov.io

express helper that caches all .pug files to memory on startup

Install

$ npm install --save express-pug-cache-helper

Usage

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);

API

pugCacheHelper(expressApp, options):

  • expressApp: express app, important: it needs to fire 'mount' event
  • options:
    • force: Forces express view cache setting to true (default undefined)
    • pugCompileOptions: Options object handed over to pug.compileFile (default {cache: true})
    • pugExt: Template file name extension (default '.pug')

Options

Use DEBUG=epch:cache to debug with debug.

Package Sidebar

Install

npm i express-pug-cache-helper

Weekly Downloads

1

Version

2.1.1

License

MIT

Last publish

Collaborators

  • antpaw