IssueRaiser

Treat layout pages like components when using named slots

Let's say I have a `_layout.svelte` like the following: ```html <slot name="layout-pre"></slot> <div id="intermediate">Some other intermediate stuff.</div> <slot></slot> ``` And now I have a child view (let's call it `homepage.svelte` which inherits that layout, which puts some stuff into the named slot, and the rest into the default slot: ```html <h1 slot="layout-pre">This should come before #intermediate.</h1> <!-- When rendered, the div from above should get inserted here from the layout: <div id="intermediate">Some other intermediate stuff.</div> --> <main>Since this doesn't use a named slot, it'll just get inserted into the unnamed slot above.</main> ``` Right now this is not allowed, and the following error is thrown: `Element with a slot='...' attribute must be a descendant of a component or custom element`. Are there technical or usage reasons why we wouldn't want to treat a layout like any other component with respect to slots?

Posted by Aias on Sep 5, 2019, 9:05 AM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,500 issues0 comments

github (Other)

Treat layout pages like components when using named slots

AiasSep 5, 2019, 9:05 AM

Let's say I have a `_layout.svelte` like the following: ```html <slot name="layout-pre"></slot> <div id="intermediate">Some other intermediate stuff.</div> <slot></slot> ``` And now I have a child view (let's call it `homepage.svelte` which inherits that layout, which puts some stuff into the named slot, and the rest into the default slot: ```html <h1 slot="layout-pre">This should come before #intermediate.</h1> <!-- When rendered, the div from above should get inserted here from the layout: <div id="intermediate">Some other intermediate stuff.</div> --> <main>Since this doesn't use a named slot, it'll just get inserted into the unnamed slot above.</main> ``` Right now this is not allowed, and the following error is thrown: `Element with a slot='...' attribute must be a descendant of a component or custom element`. Are there technical or usage reasons why we wouldn't want to treat a layout like any other component with respect to slots?

Comments (0)

No comments yet. Start the discussion.

Comment on this issue