ux: [TwigComponent] Impossible to declare higher level component content block

So I have a component A which defines it’s content block. Then I have a higher level component B which also defines it and to forward to the A component, but Twig says: The block 'content' has already been defined line 6.

{# A.html.twig #}
<{{ element }} class="{{ classes }}"{{ attributes }}>
  {%- block content -%}{%- endblock -%}
</{{ element }}>
{# B.html.twig #}
<twig:A>
  {%- block content -%}{%- endblock -%}
</twig:A>

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 24 (20 by maintainers)

Commits related to this issue

Most upvoted comments

Should I am the foo block be rendered in place, or inside the component’s div, or both? (both is simple, just pass blocks to display() in ComponentNode::compile())

That’s why I think we should stop using “blocks” for passing content into components - it’s doing 2 jobs at once and is confusing and has weird questions like this https://github.com/symfony/ux/issues/844#issuecomment-1543805445

I don’t think it is even possible to override a block from outside a component, without completely reworking the syntax/compiler, since they are not being used in an extend-flow, but an embed-flow. Or am I overlooking something?

Exactly - so let’s move away from using blocks for this! And let blocks be blocks - use a new “slot” idea like in https://github.com/giorgiopogliani/twig-components#usage