jstransformer icon indicating copy to clipboard operation
jstransformer copied to clipboard

Function signature of .compileAsync()

Open RobLoach opened this issue 10 years ago • 1 comments

Looking at normalizeFnAsync(), it seems to expect the resulting fn to be a .render() function:

function normalizeFnAsync(result, cb) {
  return Promise.resolve(result).then(function (result) {
    if (result && isPromise(result.fn)) {
      return result.fn.then(function (fn) {
        result.fn = fn;
        return result;
      });
    }
    return result;
  }).then(tr.normalizeFn).nodeify(cb);
}

This is the function that .compileAsync() calls. Since compileAsync expects to result in a render() function, it makes it difficult to work with nunjucks, since the majority of its API is asynchronous. There are other transforms that are affected by this as well.

RobLoach avatar Jul 24 '15 13:07 RobLoach

Add Promise support to compileAsync?

RobLoach avatar Jul 02 '16 05:07 RobLoach