- Issue created by @pdureau
- 🇫🇷France pdureau Paris
For information, UI Patterns 2.x team is also looking for such solution: 📌 [2.0.0-alpha3] Replace component() function by native Twig mechanisms? Active
- 🇫🇷France pdureau Paris
Remove everything but ::getNodeVisitors() in ComponentsTwigExtension and most of ComponentNodeVisitor
It would also be the opportunity to also remove ComponentElement::generateComponentTemplate() and to simply render:
[ '#type' => 'inline_template', '#template' => $template_loaded_from_file, '#context' => $slots + $props, ];
- 🇳🇿New Zealand quietone
Changes are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies.
- Status changed to Closed: won't fix
24 days ago 6:36pm 18 April 2025 - 🇫🇷France pdureau Paris
It was tied by UI Patterns team in 📌 [2.0.0-alpha3] Replace component() function by native Twig mechanisms? Active
- It was working well with
include
function - But it was not possible with
embed
tag
We can't visit EmbedNode because it doesn't know about:
- the template ID (so the component ID) because it is the parent node (an expression)
- and the blocks (so the slots) because their nodes are elswhere in the AST (in a
blocks
section)
Maybe we can introduce our own EmbedTokenParser which will know:
- the template ID (so the component ID):
$parent->getAttribute("value")
- the variables (so the props):
[$variables, $only, $ignoreMissing] = $this->parseArguments();
- and the blocks (so the slots) by exploring the ModuleNode:
$module = $this->parser->parse($stream, [$this, 'decideBlockEnd'], true);
But working at the parser level is way harder and risker than working at the AST level.
So, let's not do that. The current rendering method is not perfect but work well anyway.
- It was working well with