Open KieranP opened 2 years ago
Do you think named slots already achieve this?
@babichjacob Slots can't be passed to sibling components. This is a slimmed down version of what I have in my layout file:
<main>
<Header />
<Banner />
<Page />
</main>
Banner is where the banner contents are displayed/styled, but Page is the one that sets the banner contents. Banner contents varies per page. Currently there is no native way to set content for one component via another. I either have to bubble an event up to the parent and back down, or set content on a store, but storing HTML in a svelte store feels wrong.
I would also say that named slots are a good approach. It depends a bit on how your layout component is used.
Describe the problem
Each page has a different page header. Need a way to pass data from the main page view to a child of the layout view. Currently complicated using stores. Would clean things up using a method like Ruby on Rails content_for by allowing svelte:fragment to accept a name, and be able to call it later with svelte:content
Describe the proposed solution
In the page view:
In the page banner component:
Alternatives considered
Open to suggestions
Importance
would make my life easier