-
Notifications
You must be signed in to change notification settings - Fork 190
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
Why Twig filters and not functions? #5
Comments
It has never been a tag. It was a function: |
I agree with @mbontemps, it's not intuitive. I'm not sure about the semantic thing. A filter transforms or adapts a value that already has a "meaning" (a date for instance). It has its place as a function argument => "Go find my menu named 'main' and render it". |
the filter accept 2 things: the menu object, or the name for the menu in the provider. |
Still, IMO perhaps both filter and method should be proposed. The filter transforms a menu object, and the method takes a menu name. |
I don't think I like having both a filter and a function (which behave differently), but I think that @benjamindulau is perfectly logical: filtering the menu object makes sense, but filter a string into a full menu just doesn't feel right. Also, I think a function is more consistent with how the Symfony form framework works, and it's also consistent with how you render a menu in PHP (e.g. you pass the menu into a renderer). So, +1 for making it a function again - I just think it's a little more understandable. |
Thanks @stof! |
@stof, could you elaborate a bit on why you have chosen to replace a function by a filter, ie:
has become:
In terms of logic, it is not intuitive to me…
The text was updated successfully, but these errors were encountered: