-
Notifications
You must be signed in to change notification settings - Fork 24
Description
There are a lot of errors in the extension documentation, surrounding use of custom functions (TwingFunction). For example:
If you want to access the current context in your filter, set the
needs_contextoption totrue. Twing will pass the current context as the first argument to the filter call (or the second one ifneeds_environmentis also set totrue):
let filter = new TwingFilter('rot13', function (env, context, string) {
// ...
}, {needs_context: true, needs_environment: true});Of course, I am citing the filter documentation even though I am using functions because there are only examples and explanations given for filters and we are lead to believe they both operate alike.
First of all, passing options to the third parameter will do nothing whatsoever because the third parameter is some undocumented feature called acceptedArguments of type TwingCallableArgument[]. Whilst we're on the topic of this weird parameter, it's also a required field, so if you're coding in TypeScript, it's an error not to specify it, even though we can have no idea what it does.
Second, if one wants the environment, one must actually pass needs_template because there is no option called needs_environment.
This is all very misleading and confusing and it's unclear what is a documentation error or what might be an implementation error.