Skip to content

About

PostHTML for Hapi

Resources

Contributing

Stars

1 star

Watchers

3 watching

Forks

Latest commit

 

History

23 Commits

Folders and files

Repository files navigation

Warning

This package is no longer maintained. It will not receive updates, fixes or support. PostHTML itself can be used directly: https://github.com/posthtml/posthtml

NPM Deps Tests Coverage Standard Code Style Chat

Hapi PostHTML

Install

npm i -S hapi-posthtml

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


Michael Ciniawsky

Contributing

See PostHTML Guidelines and contribution guide.

LICENSE

MIT

About

PostHTML for Hapi

Resources

Contributing

Stars

1 star

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages