mixxorz / slippers

A UI component framework for Django. Built on top of Django Template Language.
https://mitchel.me/slippers/
MIT License
506 stars 37 forks source link

Components with N children #12

Closed CleitonDeLima closed 2 years ago

CleitonDeLima commented 2 years ago

Hi

I really liked this component approach that slippers does, an idea came to me for a component to have more than one child. Do you think this would have adoption in the lib? I can think of some ideas for that.

mixxorz commented 2 years ago

You can achieve this using fragments. From the docs:

{% fragment as my_fragment %}
  <p>Hello, World!</p>
{% endfragment %}

{# Output the HTML #}
{{ my_fragment }}

{# Pass it around #}
{% my_component content=my_fragment %}
{% include "my_app/my_other_component.html" with content=my_fragment %}

I'm hesitant to do any more than this though... In general I would like to stick to the React mental model and this is sort of how you can have "multiple children" in React.