1.0.3 • Published 10 months ago

hbs-async-helpers v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

HBS Async Helpers

Library that adds support for asynchronous function helpers to the handlebars template engine.

How to install

npm i hbs-async-helpers

How to import

CommonJS

const Handlebars = require("handlebars");
const asyncHelpers = require("hbs-async-helpers");

ES6

import Handlebars from 'handlebars',
import asyncHelpers from 'hbs-async-helpers';

Usage

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

Acknowlegments

This package has been forked from handlebars-async-helpers originally created and maintained by Gaston Robledo.

1.0.2

11 months ago

1.0.3

10 months ago

1.0.1

12 months ago

1.0.0

2 years ago