-
-
Notifications
You must be signed in to change notification settings - Fork 312
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
[Twig] Add attributes()
twig function
#1414
base: 2.x
Are you sure you want to change the base?
Conversation
Similar twig core issues/PRs: twigphp/Twig#3930, twigphp/Twig#3907, twigphp/Twig#3760 |
The function name <div{{ attributes }}> {# correct #}
<div{{ attributes() }}> {# wrong #}
|
That's a great idea, it would also close #940 since the main idea was to easily renders attributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love that 🧡
Yes, I agree here. I like How it's gonna work with Live components for example? <div attributes({role: 'alert', class='text-blue-800 px-4', ...attributes})>
...
</div> |
Would love to have this in Twig itself :) |
… (kbond) This PR was merged into the 2.x branch. Discussion ---------- [Twig] Make `ComponentAttributes` traversable/countable | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | Issues | n/a | License | MIT This will help with #1405 and #1414. Commits ------- 8040d9c feat(twig): make `ComponentAttributes` traversable/countable
This allows passing attributes to elements easier.
When/if #1413 is merged, the following will also be possible: