- Issue created by @pdureau
- Assigned to mogtofu33
- Status changed to Postponed
5 months ago 10:09am 20 June 2024 - 🇫🇷France pdureau Paris
Postponed because there is no clear solution now.
Jean: "We can override
embed
andinclude
in Twig, but the props & slots are not easily available once they are transformed as variable in the Twig template." - Issue was unassigned.
- 🇫🇷France mogtofu33
Here is a starting point before reaching the problem of re-mapping props and slots from Twig Node to Drupal render array API.
And another issue is how to pass the render array to Twig for render throw `render_var`.
- Status changed to Active
4 months ago 4:23pm 31 July 2024 - 🇫🇷France pdureau Paris
In a way, it is more or less what SDC is doing:
ComponentsTwigExtension is adding 2 twig functions:
add_component_context
which is adding the attribute Attribute object if missingvalidate_component_props
which is executing the JSON schema validator
They are not supposed to be used by templates owner, there exists because ComponentNodeVisitor is printing those Twig functions on every template, which will be executed on rendering in this order:
- attach_library
- add_component_context
- validate_component_props
In order to make the use of "template to template" Twig functions or tags (
include
andembed
) more similar to the use of the Render API, leveraging the render element. For example,attach_library
is used here because#attached
is not executed. - 🇫🇷France pdureau Paris
First proposal for
include
: https://git.drupalcode.org/project/ui_patterns/-/merge_requests/262/diffsIt was the easy one.
embed
will be an harder challenge