Skip to content

pocketken/handlebars-async-helpers

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Handlebars Async Helpers

Library that adds support to asynchronous function helpers to handlebars lib.

How to install

npm install handlebars-async-helpers

Hot wo use it.

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!'

About

Adding async functions support to handlebars

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%