Skip to content

Commit 230d405

Browse files
Rich-Harrisgithub-actions[bot]
authored andcommitted
sync svelte docs
1 parent 42bd7b8 commit 230d405

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

apps/svelte.dev/content/docs/svelte/99-legacy/20-legacy-slots.md

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -74,39 +74,45 @@ If no slotted content is provided, a component can define fallback content by pu
7474

7575
Slots can be rendered zero or more times and can pass values _back_ to the parent using props. The parent exposes the values to the slot template using the `let:` directive.
7676

77-
The usual shorthand rules apply — `let:item` is equivalent to `let:item={item}`, and `<slot {item}>` is equivalent to `<slot item={item}>`.
78-
7977
```svelte
80-
<!-- FancyList.svelte -->
78+
<!--- file: FancyList.svelte --->
8179
<ul>
82-
{#each items as item}
80+
{#each items as data}
8381
<li class="fancy">
84-
<slot prop={item} />
82+
<!-- 'item' here... -->
83+
<slot item={process(data)} />
8584
</li>
8685
{/each}
8786
</ul>
87+
```
8888

89-
<!-- App.svelte -->
90-
<FancyList {items} let:prop={thing}>
91-
<div>{thing.text}</div>
89+
```svelte
90+
<!--- file: App.svelte --->
91+
<!-- ...corresponds to 'item' here: -->
92+
<FancyList {items} let:item={processed}>
93+
<div>{processed.text}</div>
9294
</FancyList>
9395
```
9496

97+
The usual shorthand rules apply — `let:item` is equivalent to `let:item={item}`, and `<slot {item}>` is equivalent to `<slot item={item}>`.
98+
9599
Named slots can also expose values. The `let:` directive goes on the element with the `slot` attribute.
96100

97101
```svelte
98-
<!-- FancyList.svelte -->
102+
<!--- file: FancyList.svelte --->
99103
<ul>
100104
{#each items as item}
101105
<li class="fancy">
102-
<slot name="item" {item} />
106+
<slot name="item" item={process(data)} />
103107
</li>
104108
{/each}
105109
</ul>
106110
107111
<slot name="footer" />
112+
```
108113

109-
<!-- App.svelte -->
114+
```svelte
115+
<!--- file: App.svelte --->
110116
<FancyList {items}>
111117
<div slot="item" let:item>{item.text}</div>
112118
<p slot="footer">Copyright (c) 2019 Svelte Industries</p>

0 commit comments

Comments
 (0)