-
Notifications
You must be signed in to change notification settings - Fork 43
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
How to create new custom functions as the built in functions...? #78
Comments
(Please file issues about the JavaScript implementation in https://github.com/projectfluent/fluent.js.) Fluent Functions, including custom builtins, take positional arguments as well as keyword arguments, which isn't supported by JavaScript out of the box. So instead, we make them accept two arguments: an array of positional args and an object keyword args. See the example of And here's the line which calls Functions: https://github.com/projectfluent/fluent.js/blob/dddb5db19bd5fc6a95a251cd7059cf26f187548d/fluent/src/resolver.js#L417 I think your example should work if you change the // Destructure the array of positional arguments to flag_value.
FLAG([flag_value]) {
return flag_value? 'active' : 'inactive';
} |
BTW this is a really nice usage of custom builtins! |
Thanks! So now your suggestion does the trick really well ;) // Destructure the array of positional arguments to flag_value.
FLAG([flag_value]) {
return flag_value? 'active' : 'inactive';
} Thanks again for your fast answer ;) I will post anything related with the implementation on fluent.js next time ;) |
I'm happy I was able to help! |
Hi again
I am trying to do this kind of function:
But no idea how to do it... I don't know how to get the
flag_value
:The text was updated successfully, but these errors were encountered: