You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
registerAsyncHelper has a limit of two arguments to the helper, which is confusing, and doesn't allow direct ports from a handlebars helper, to an express-hbs helper.
Here's an example of a helper that is impossible to make async with the current system:
// usage: {{someHelper "first" "second"}}// usage: {{someHelper "first" "second" key="val"}}hbs.registerHelper('someHelper',function(arg1,arg2,options){// arg1 === "first"// arg2 === "second"// options.hash === {} || {key: "val"}});// usage: {{someAsyncHelper "first" "second"}}// usage: {{someAsyncHelper "first" "second" key="val"}}hbs.registerAsyncHelper('someAsyncHelper',function(arg1,arg2,options,done){// this won't work// arg1 === "first"// arg2 === "second"// options === Function// done === undefined// `options` object will not be passed at all, meaning no access to the `hash`});
This is particularly an issue with block helpers, as they almost always want access to the options object in order to call options.fn to render their "insides"
I think it would make sense for registerAsyncHelper to replicate the registerHelper signature, with an extra argument passed at the end - OR to replicate the registerHelper signature exactly, and allow returning of a Promise
Unfortuantely fixing this would be a major version bump.
The text was updated successfully, but these errors were encountered:
registerAsyncHelper
has a limit of two arguments to the helper, which is confusing, and doesn't allow direct ports from ahandlebars
helper, to anexpress-hbs
helper.Here's an example of a helper that is impossible to make async with the current system:
This is particularly an issue with block helpers, as they almost always want access to the
options
object in order to calloptions.fn
to render their "insides"I think it would make sense for
registerAsyncHelper
to replicate theregisterHelper
signature, with an extra argument passed at the end - OR to replicate theregisterHelper
signature exactly, and allow returning of aPromise
Unfortuantely fixing this would be a major version bump.
The text was updated successfully, but these errors were encountered: