0.0.3 • Published 9 years ago

hapi-consolidate v0.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
9 years ago

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