jonschlinkert / engine

Alternative to Lo-Dash template with support for helpers.
https://github.com/jonschlinkert
Other
17 stars 5 forks source link

Async helpers support #6

Open tunnckoCore opened 5 years ago

tunnckoCore commented 5 years ago

Will be good to support it out of the box.

With https://github.com/doowb/async-helpers/pull/19 it will be nothing more than just calling its .set. If the helper is regular async or callback async function it will be handled/wrapped by the async-helpers, otherwise it will be just set in the this.helpers. With .get() you will get both the wrapped and non-wrapped ones.

tunnckoCore commented 5 years ago
  helper(prop, fn) {
    if (utils.isObject(prop)) {
      this.helpers(prop);
    } else {
      this.asyncHelpers.set(prop, fn);
    }
    return this;
  }

  helpers(helpers) {
    this.asyncHelpers.set(helpers);
    return this;
  }

  // later merge `this.imports` and `this.asyncHelpers.helpers`

Probably would be good thing to just rename the this.helpers in async-helpers to be this.imports so will be able to extend the AsyncHelpers class here.