Skip to content

[TwigComponent] Issue with nested blocks using HTML syntax #2104

Closed
@javiereguiluz

Description

@javiereguiluz

I'm using Twig components (not Live components) and they work great even when nesting them. But, I'm facing an issue with some nested component when using the HTML syntax:

<twig:Card:Group mdCols="2" xlCols="3">
    {% for event in events %}
        <twig:Card:Card isClickable="{{ true }}">
            {% block title %} ... {% endblock %}
            {% block body %} ... {% endblock %}
            {% block footer %}
                <twig:Button isBlock="{{ true }}" data-bs-toggle="dropdown">
                    Add to Calendar
                </twig:Button>

                {# ... #}
            {% endblock %}
        </twig:Card:Card>
    {% endfor %}
</twig:Card:Group>

The <twig:Button ...> nested component is not rendered. In the output HTML you see the raw <twig:Button ...> code.


This works correctly:

<twig:Card:Group mdCols="2" xlCols="3">
    {% for event in events %}
+        {% set button %}
+            <twig:Button isBlock="{{ true }}" data-bs-toggle="dropdown">
+                Add to Calendar
+            </twig:Button>
+        {% endset %}
        
        <twig:Card:Card isClickable="{{ true }}">
            {% block title %} ... {% endblock %}
            {% block body %} ... {% endblock %}
            {% block footer %}
+                {{ button }}
-                <twig:Button isBlock="{{ true }}" data-bs-toggle="dropdown">
-                    Add to Calendar
-                </twig:Button>

                {# ... #}
            {% endblock %}
        </twig:Card:Card>
    {% endfor %}
</twig:Card:Group>

Using the other Twig component syntax works too:

<twig:Card:Group mdCols="2" xlCols="3">
    {% for event in events %}
        <twig:Card:Card isClickable="{{ true }}">
            {% block title %} ... {% endblock %}
            {% block body %} ... {% endblock %}
            {% block footer %}
-                <twig:Button isBlock="{{ true }}" data-bs-toggle="dropdown">
-                    Add to Calendar
-                </twig:Button>
+                 {% component Button with {isBlock: true, 'data-bs-toggle': 'dropdown'} %}
+                     {% block content %}Add to calendar{% endblock %}
+                 {% endcomponent %}

                {# ... #}
            {% endblock %}
        </twig:Card:Card>
    {% endfor %}
</twig:Card:Group>

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions