From 55b11b0664ba176cc7af3f7fdeb9dac00a2bc6e6 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Mon, 25 Jan 2021 17:50:53 -0800 Subject: [PATCH] docs: define component before demonstrating usage (#5921) --- site/content/docs/02-template-syntax.md | 61 +++++++++++++------------ 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/site/content/docs/02-template-syntax.md b/site/content/docs/02-template-syntax.md index 7288b8e8dd..2c665376dc 100644 --- a/site/content/docs/02-template-syntax.md +++ b/site/content/docs/02-template-syntax.md @@ -1292,19 +1292,19 @@ Components can have child content, in the same way that elements can. The content is exposed in the child component using the `` element, which can contain fallback content that is rendered if no children are provided. ```sv - - - - -

this is some child content that will overwrite the default slot content

-
-
this fallback content will be rendered when no content is provided, like in the first example
+ + + + + +

this is some child content that will overwrite the default slot content

+
``` #### [``](slot_name) @@ -1314,18 +1314,18 @@ The content is exposed in the child component using the `` element, which Named slots allow consumers to target specific areas. They can also have fallback content. ```sv - - -

Hello

-

Copyright (c) 2019 Svelte Industries

-
-
No header was provided

Some content between header and footer

+ + + +

Hello

+

Copyright (c) 2019 Svelte Industries

+
``` #### [`$$slots`](slots_object) @@ -1337,20 +1337,21 @@ Named slots allow consumers to target specific areas. They can also have fallbac Note that explicitly passing in an empty named slot will add that slot's name to `$$slots`. For example, if a parent passes `
` to a child component, `$$slots.title` will be truthy within the child. ```sv - - -

Blog Post Title

-
-
{#if $$slots.description} - +
{/if}
+ + + +

Blog Post Title

+ +
``` #### [``](slot_let) @@ -1362,11 +1363,6 @@ Slots can be rendered zero or more times, and can pass values *back* to the pare The usual shorthand rules apply — `let:item` is equivalent to `let:item={item}`, and `` is equivalent to ``. ```sv - - -
{thing.text}
-
-
    {#each items as item} @@ -1375,6 +1371,11 @@ The usual shorthand rules apply — `let:item` is equivalent to `let:item={item} {/each}
+ + + +
{thing.text}
+
``` --- @@ -1382,12 +1383,6 @@ The usual shorthand rules apply — `let:item` is equivalent to `let:item={item} Named slots can also expose values. The `let:` directive goes on the element with the `slot` attribute. ```sv - - -
{item.text}
-

Copyright (c) 2019 Svelte Industries

-
-
    {#each items as item} @@ -1398,6 +1393,12 @@ Named slots can also expose values. The `let:` directive goes on the element wit
+ + + +
{item.text}
+

Copyright (c) 2019 Svelte Industries

+
```