Adding async function support to handlebars helpers
npm install handlebars-async-helpersLibrary that adds support to asynchronous function helpers to handlebars lib.
shell
npm install handlebars-async-helpers
`$3
`javascript
const handlebars = require('handlebars'),
asyncHelpers = require('handlebars-async-helpers')const hb = asyncHelpers(handlebars)
hb.registerHelper('sleep', async () => new Promise((resolve) => {
setTimeout(() => resolve('Done!'), 1000)
}))
const template = hb.compile('Mark when is completed: {{#sleep}}{{/sleep}}')
const result = await template()
console.log(result)
// 'Mark when is completed: Done!'
``