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
- bug #859 [TwigComponent] Fixing bug where traditional blocks aren't handled correctly (weaverryan) This PR was squashed before being merged into the 2.x branch. Discussion ---------- [TwigComponent... — committed to symfony/ux by weaverryan a year ago
- feature #920 [TwigComponent] Support passing blocks to nested embedded components (sneakyvv) This PR was squashed before being merged into the 2.x branch. Discussion ---------- [TwigComponent] Supp... — committed to symfony/ux-twig-component by weaverryan a year ago
- bug #859 [TwigComponent] Fixing bug where traditional blocks aren't handled correctly (weaverryan) This PR was squashed before being merged into the 2.x branch. Discussion ---------- [TwigComponent... — committed to web9app6/ux by web9app6 a year ago
- feature #920 [TwigComponent] Support passing blocks to nested embedded components (sneakyvv) This PR was squashed before being merged into the 2.x branch. Discussion ---------- [TwigComponent] Supp... — committed to jrushlow/ux by weaverryan a year ago
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
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