Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TwingFunction just doesn't seem to work #537

Closed
Bilge opened this issue Aug 28, 2021 · 1 comment
Closed

TwingFunction just doesn't seem to work #537

Bilge opened this issue Aug 28, 2021 · 1 comment

Comments

@Bilge
Copy link

Bilge commented Aug 28, 2021

When adding the most trivial custom function such as the following:

twing.addFunction(new TwingFunction('is_granted', _ => true));

the browser error as follows:

TwingErrorRuntime: An exception has been thrown during the rendering of a template ("callable.apply(...).catch is not a function") in "C:/templates/component/tier.twig".
traceableCallable callable-wrapper.js:44
doDisplay tier.twig:22
displayWithErrorHandling template.js:319
display template.js:316
promise callbackdisplay template.js:316
render template.js:337
exports tier.twig:50
promise callback
../templates/component/tier.twig/module.exports tier.twig:50

Indeed, I'm not sure why it expects there would be a property called catch attached to my anonymous function?

return (callable.apply(null, arguments) as Promise<T>).catch((e: TwingError) => {

@Bilge
Copy link
Author

Bilge commented Aug 28, 2021

It seems I need to use Promise.resolve(true) for reasons that remain unclear to me.

@Bilge Bilge closed this as completed Aug 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant