Skip to content

Nested slots don't work  #34

Closed
Closed

Description

@danjac

Example:

  {% slot form_footer %}
  <div class="flex items-center justify-end">
    {% slot form_buttons %}{% endslot %}
  </div>
  {% endslot %}

I use the component thus:

{% component_block "form" %}
{% slot form_buttons %}
<button>Submit</button>
{% endslot %}
{% endcomponent_block %}

The content of the form_buttons is not overridden, i.e. it's empty. Only the outer content of form_footer is rendered:

  <div class="flex items-center justify-end">
  </div>

Activity

  1. EmilStenstrom commented on Feb 20, 2021

    @EmilStenstrom
    Collaborator

    Ah, makes sense that nested slots, just like nested blocks, should work.

    Internally the slots are handled as a list, so supporting this would mean handling them as a tree instead. Not trivial, but doable I think.

    Mind giving it a try?

  2. danjac commented on Feb 20, 2021

    @danjac
    ContributorAuthor

    I'm not very familiar with the underlying template tag code, but naively could you run the same code as do_component_block() inside the slot tag: so each slot just renders its own list of slots?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions