hapi-hogan
v1.0.2
Published
Hogan.js templating in Hapi.js
Downloads
10
Maintainers
Readme
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