Skip to content

Okoyl/hapi-consolidate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Hapi.js template rendering using consolidate.

Resources

License

Stars

Watchers

Forks

Packages

No packages published