Skip to content

[Twig] Allow more flexible twig expressions as component attributes #534

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

Merged
merged 1 commit into from
Nov 7, 2022

Conversation

veewee
Copy link
Contributor

@veewee veewee commented Nov 7, 2022

Q A
Bug fix? no
New feature? yes
Tickets
License MIT

We noticed it is only possible to pass an ArrayExpression as twig component attributes.
This is not convenient of you want to e.g. merge 2 arrays in twig.

Example Use-case: if you want to create a custom form template that consists out of twig components, it is not possible to merge the form attributes into the attributes of your twig component.

{%- block button_widget -%}
    {% component 'atoms:button' with attrs|merge({theme: 'primary'}) %}
        {% block children %}
            {{ label }}
        {% endblock children %}
    
    {% endcomponent %}
{%- endblock button_widget -%}

Copy link
Member

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool 😎

@weaverryan
Copy link
Member

Thanks @veewee!

@weaverryan weaverryan merged commit 05ad23f into symfony:2.x Nov 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants