- Issue created by @hctom
- Status changed to Needs review
about 1 year ago 2:47pm 14 January 2024
I am currently facing a lot of problems, when trying to nest components in Storybook - especially for components with slots/blocks. I tried different solutions like templates from string, a custom Twig function to render a component etc.
Unfortunately all of these lead to problems like block name collisions, double-escaped strings or unprocessed Twig markup in components deeper than level one in the embed tree.
Fortunately the SDC module allows render arrays for slot content, which would make it really easy to e.g. embed a component into another component via '#type' => 'component'
render arrays (with unlimited nesting depth). But unfortunately the cl_server
module is only able to handle string values for slots.
text
component with a text
slot for the actual text markupfigcaption
component with a text
slot, where a text
component should be included (or any another component)figure
component with a caption
slot, where a figcaption
component should be included (or any another component)figure
component embeds figcaption
component, which itself embeds text
component) by using a similar syntax like in the example from the docs - but we cannot use {% include %}
here due to the slots and have to use {% embed %}
insteadServerEndpointController::generateRenderArray()
(as they are already allowed by SDC module)n/a
ServerEndpointController::render()
controller will allow render arrays as slot values (which will also be handy to allow using '#type' => 'markup'
render arrays for sending HTML code from Storybook to a component slot while avoiding duplicate escaping)n/a
Needs review
2.0
Code