mixxorz / slippers

A UI component framework for Django. Built on top of Django Template Language.

Home Page:https://mitchel.me/slippers/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add named slots

alex-way opened this issue · comments

It would be really cool if you could have both named and unnamed slots, rather than children - Similar to Astro and Svelte.

I guess this is actually possible using fragments, although I would prefer it if the fragment was defined within the body of the component to assure that it was co-located.

Happy with fragments for now though.

Could you show an example how this can be achieved with fragments?

@mschoettle
It's possible with code similar to the below:

<!-- components/button_with_label.html -->
<label>{{ label_text }}</label>
<button>{{ button_text }}</button>
<!--templates/index.html-->
{% fragment as button_text %}
Hello button
{% endfragment %}
{% fragment as label_text %}
Hello label
{% endfragment %}
{% #button_with_label button_text=button_text label_text=label_text %}{% /button_with_label %}