how to render handlebars layout partials with koa-views
Robin-front opened this issue · 2 comments
Robin-front commented
I try to run this,
Handlebars.registerPartial('myPartial', '{{name}}')
but, it doesn't work
Janking commented
@Robin-front 问题解决了吗?I have the same question ...
queckezz commented
const app = new Koa()
.use(views(__dirname, {
map: { hbs: 'handlebars' },
options: {
partials: {
subTitle: './my-partial' // requires ./my-partial.hbs
}
}
}))
.use(function (ctx) {
ctx.state = { title: 'my title', author: 'queckezz' }
return ctx.render('./my-view.hbs')
})