https://github.com/posthtml/hapi-posthtml
PostHTML for Hapi
https://github.com/posthtml/hapi-posthtml
Last synced: 4 months ago
JSON representation
PostHTML for Hapi
- Host: GitHub
- URL: https://github.com/posthtml/hapi-posthtml
- Owner: posthtml
- License: mit
- Created: 2016-03-04T17:26:32.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-08-01T22:28:25.000Z (over 9 years ago)
- Last Synced: 2024-10-29T21:06:03.267Z (over 1 year ago)
- Language: JavaScript
- Size: 16.6 KB
- Stars: 1
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
[![NPM][npm]][npm-url]
[![Deps][deps]][deps-url]
[![Tests][build]][build-url]
[![Coverage][cover]][cover-url]
[![Standard Code Style][style]][style-url]
[![Chat][chat]][chat-badge]
# Hapi PostHTML 
## Install
```bash
npm i -S hapi-posthtml
```
## Usage
```js
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](https://github.com/posthtml/posthtml/tree/master/docs) and [contribution guide](CONTRIBUTING.md).
## LICENSE
[MIT](LICENSE)
[npm]: https://img.shields.io/npm/v/hapi-posthtml.svg
[npm-url]: https://npmjs.com/package/hapi-posthtml
[deps]: https://david-dm.org/posthtml/hapi-posthtml.svg
[deps-url]: https://david-dm.org/posthtml/hapi-posthtml
[build]: http://img.shields.io/travis/posthtml/hapi-posthtml.svg
[build-url]: https://travis-ci.org/posthtml/hapi-posthtml
[cover]: https://coveralls.io/repos/github/posthtml/hapi-posthtml/badge.svg?branch=master
[cover-url]: https://coveralls.io/github/posthtml/hapi-posthtml?branch=master
[style]: https://img.shields.io/badge/code%20style-standard-yellow.svg
[style-url]: http://standardjs.com/
[chat]: https://badges.gitter.im/posthtml/posthtml.svg
[chat-badge]: https://gitter.im/posthtml/posthtml?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge"