Inject sub-components from context
See original GitHub issueHi,
Thanks so much for your work on Fractal.
I am the maintainer of the Drupal integration of Fractal: https://www.drupal.org/project/ui_patterns_fractal
According to the Fractal documentation, we need to set the sub-components inside the template file:
<div class="searchbox">
<input type="search" name="keywords">
{{> @button }}
</div>
https://fractal.build/guide/components/sub-components
It would be very useful to be able to keep those templates “sub-components agnostic”, by specifying a simple variable:
<div class="searchbox">
<input type="search" name="keywords">
{{ submit }}
</div>
And inject the sub-component from the description file context. For example:
title: Search Box
context:
submit: @button
Other proposal, with context overriding:
title: Search Box
context:
submit:
render: @button
text: Go!
For Drupal integration, it is a must-have, because its render system works like that: https://www.drupal.org/docs/8/api/render-api/render-arrays
And I strongly believe this mechanism would be useful even for non-Drupal people.
Is it already possible with Fractal?
PS: I am using the Twig engine by the way: https://github.com/frctl/twig
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:8 (2 by maintainers)
Top GitHub Comments
https://github.com/frctl/fractal/issues/278#issuecomment-316977660
This has been recently implemented in #573