Skip to content

Commit

Permalink
Docs: document rest in array/object destructuring in each blocks
Browse files Browse the repository at this point in the history
Closes #2676
  • Loading branch information
mindrones committed Jun 22, 2019
1 parent fee4d35 commit 369b087
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion site/content/docs/01-component-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Svelte uses the `export` keyword to mark a variable declaration as a *property*
// Values that are passed in as props
// are immediately available
console.log(foo, bar);
// Function expressions can also be props
export let format = (number) => (number.toFixed(2));
Expand Down
15 changes: 11 additions & 4 deletions site/content/docs/02-template-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,19 @@ If a *key* expression is provided — which must uniquely identify each list ite

---

You can freely use destructuring patterns in each blocks.
You can freely use the destructuring pattern in each blocks, the rest syntax being supported.

```html
{#each items as { id, name, qty }, i (id)}
```sv
{#each items as {id, name, qty}, i (id)}
<li>{i + 1}: {name} x {qty}</li>
{/each}
{#each objects as {id, ...rest}}
<li><span>{id}</span><MyComponent {...rest} /></li>
{/each}
{#each items as [id, ...rest]}
<li><span>{id}</span><MyComponent values={rest} /></li>
{/each}
```

---
Expand Down Expand Up @@ -1351,4 +1358,4 @@ The `<svelte:options>` element provides a place to specify per-component compile

```html
<svelte:options tag="my-custom-element"/>
```
```

0 comments on commit 369b087

Please sign in to comment.