-
-
Notifications
You must be signed in to change notification settings - Fork 327
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
[TwigComponent] Unexpected attribute parsing behavior #2455
Comments
What about |
Ah dangit, somehow that documentation bit kept eluding me 🤦🏻. Maybe to mention it again briefly under |
Mmmh, I don't know, because it is related to the HTML syntax 🤔 But maybe it can be interesting to also have it in this section, do you feel opening a PR? 🙏🏻 |
Completely understandable; I can only speak from my own experience as someone who's been periodically consuming that documentation over the course of a few months and yet still managed to not stumble upon the info in question 😅
Sure thing, opened as #2457 |
You cannot do this to pass parameters to an include or embed block in Twig. So this is all but a bug :) I’m closing here as thanks to you the first item will be better documented. |
Disagree. I am not comparing it with This is comparable to (and to a large degree emulates) regular HTML like: <input
{% if condition %}
disabled
{% endif %}
/> |
This is not comparable, in fact. Using And you cannot type |
Just to clarify and confirm if we're on the same page; the TwigComponent HTML syntax is syntactic sugar and therefore implementing tags like |
Absolutely. You could also see it as an "extension" of the Twig language.
This is not really a something related to the HTML syntax but to Twig. And languages in general. Tags cannot be opened in other tags or in expressions. In the same way you cannot in php use a structure in a method call. // This is not possible (controle structure)
$obj->{if ($foo) { echo 'foo'; }}()
// This is possible (expression)
$obj->{$foo ? 'foo' : 'bar'}()
Well, as i see it, this works in the opposite direction. Twig Component features are developed in (Twig and PHP) then supported in the HTML syntax. The choice of implementing it using the |
These may be two very different reports with different opinions for each, so please let me know if you'd like me to separate them.
Example 01: Passing attributes as-isA realistic usecase for this is creating higher-order (wrapper) components.
Example 02
Most notably, without these conditions, boolean attributes seem impossible (?), but would also just make the syntax more consistent with the way Twig is normally written.
Both result in:
The text was updated successfully, but these errors were encountered: