Skip to content

Commit e769f03

Browse files
committed
docs
1 parent 0be3ba6 commit e769f03

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

documentation/docs/03-template-syntax/03-each.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,30 @@ You can freely use destructuring and rest patterns in each blocks.
7474
{/each}
7575
```
7676

77+
## Each blocks without an item
78+
79+
```svelte
80+
<!--- copy: false --->
81+
{#each expression}...{/each}
82+
```
83+
84+
```svelte
85+
<!--- copy: false --->
86+
{#each expression, index}...{/each}
87+
```
88+
89+
In case you just want to render an item `n` times, you can omit the `as` part
90+
91+
```svelte
92+
{#each { length: 10 }}
93+
<li>I am rendered 10 times</li>
94+
{/each}
95+
96+
{#each array, index}
97+
<li>I am item number {index}</li>
98+
{/each}
99+
```
100+
77101
## Else blocks
78102

79103
```svelte

0 commit comments

Comments
 (0)