jstransformer
jstransformer copied to clipboard
Function signature of .compileAsync()
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.
Add Promise support to compileAsync?