Skip to content

[TwigComponent] Nested component doesn't work with html syntax #805

@Jupi007

Description

@Jupi007

Let's assume two component foo and bar, which both define a content block.

Using the normal syntax, it works as expected:

{% component foo %}
  {% block content %}
    {% component bar %}
      {% block content %}
        {# ... #}
      {% endblock %}
    {% endcomponent %}
  {% endblock %}
{% endcomponent %}

But using the html syntax:

<twig:foo>
  <twig:block name="content">
    <twig:bar>
      <twig:block name="content">
        {# ... #}
      </twig:block>
    </twig:bar>
  </twig:block>
</twig:foo>

This throw a SyntaxError:

An exception has been thrown during the compilation of a template ("Expected closing tag '</twig:block>' for block 'content' at line 13").

Btw, simply write it like this doesn't work too:

<twig:foo>
  <twig:bar>
    {# ... #}
  </twig:bar>
</twig:foo>

This one throw:

A template that extends another one cannot include content outside Twig blocks. Did you forget to put the content inside a {% block %} tag?

But maybe it is how it is expected to work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions