hapi-hogan

1.0.2 • Public • Published

hapi-hogan

var Hapi = require('hapi')
  , hogan = require('hapi-hogan')
 
server = new Hapi.Server()
server.connection({host:'localhost', port:3000})
 
server.route({method:'GET', path:'/', handler:function (req, res) {
    res.view('layout', {name:'simo', partials: {header:'header'}})
  }
})
server.views({
  relativeTo:__dirname,
  path:'./views',
  engines: {
    html:{
      module: hogan,
      compileMode: 'sync',
      compileOptions: {
        partialsPath: path.join(__dirname, 'partials'),
        isCached: true
      }
    }
  }
})
server.start()

Just like in consolidate pass your partials using the partials key

server.route({method:'GET', path:'/', handler:function (req, res) {
    res.view('layout', {name:'simo', partials: {header:'header'}})
  }
})

Here header is the name of your {{>header}} partial and the 'header' string is the relative path to it. In the above example thats the header.html file located in the partials folder

server.views({
  relativeTo:__dirname,
  path:'./views',
  engines: {
    html:{
      module: hogan,
      compileMode: 'sync',
      compileOptions: {
        partialsPath: path.join(__dirname, 'partials'),
        isCached: true
      }
    }
  }
})

partialsPath is the absolute path to your partials folder. The partials are cached by default, to disable it set isCached to false. Both of these two options should be placed inside the compileOptions key

Package Sidebar

Install

npm i hapi-hogan

Weekly Downloads

7

Version

1.0.2

License

MIT

Last publish

Collaborators

  • simov