Install
Usage
import Hapi from 'hapi' import vision from 'vision' import posthtml from 'hapi-posthtml' const server = new Hapi.Server() // Create server server.connection({ host: 'localhost', port: 3000 }) // Vision for view support server.register(vision, err => { if (err) { throw err } // PostHTML server.views({ path: 'public/views/', engines: { 'html': posthtml }, relativeTo: __dirname, compileMode: 'async' compileOptions: { // PostHTML Plugins plugins: [/* Plugins */] } }) }) // Create route handlers const handlers = { root: function (request, reply) { reply.view('index') }, local: function (request, reply) { reply.view('index', { plugins: [/* Plugins */] }) }, extend: function (request, reply) { reply.view('index', { plugins: [/* Plugins */], extend: true}) } } // Create routes server.route({ method: 'GET', path: '/', handler: handlers.root }) server.route({ method: 'GET', path: '/local', handler: handlers.local }) server.route({ method: 'GET', path: '/extend', handler: handlers.extend }) server.start((err) => { if (err) { throw err } console.log('=> Server:', server.info.uri) })
Maintainers
Contributing
See PostHTML Guidelines and contribution guide.