Open MacgyverMartins opened 8 years ago
:+1:
The "problem" is most likely that Handlebars itself does not support async helper (feature suggestion | Synchronous/Asynchronous Helpers #717), the ability to have an async helper in express-hbs
is a hack on top of handlebars.
For those who still might be interested:
your HTML
{{renderAsync 'some context'}}
your JS
hbs.registerAsyncHelper( 'renderAsync', async function renderAsync( context, helperFn, resolver ) {
// await doAsyncStuff();
resolver( `<p> rendered HTML </p>` )
}
)
First of all, sorry for my bad english. I need write a helper that do a query on mongodb. This helper should be async, like de registerAsyncHelper from express-hbs:
How can I do this with express-handlebars? I try return a promise, but it's not work. I am beginner with node and handlebars, so sorry if this is a stupid question.