Hapi.js template rendering using consolidate.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
README.md
package.json
plugin.js

README.md

hapi-consolidate

Hapi.js dynamic template rendering using consolidate. hapi-consolidate adds two new methods to the server and reply interfaces of Hapi.js.

Installation

npm install --save hapi-consolidate

Example

const Hapi = require("hapi");
const path = require("path");
const server = new Hapi.Server();
server.connection({port: 8080});

server.register(require("hapi-consolidate"), err => {
  if (err) throw err;
  server.consolidate({
    name: "pug",
    path: path.resolve(__dirname, 'views'),
    extension: 'pug',
    options: {
      cache: true
    }
  });
});

server.route({
  method: 'GET',
  path: '/',
  config: {
    handler: (request, reply) => {
      reply.render('index', {username: 'admin'});
    }
  }
});

server.start(err => {
  if (err) throw err;
});