Docs: document rest in array/object destructuring in each blocks

Closes #2676
pull/2677/head
Luca Bonavita 6 years ago
parent fee4d351e1
commit 369b087d09

@ -47,7 +47,7 @@ Svelte uses the `export` keyword to mark a variable declaration as a *property*
// Values that are passed in as props // Values that are passed in as props
// are immediately available // are immediately available
console.log(foo, bar); console.log(foo, bar);
// Function expressions can also be props // Function expressions can also be props
export let format = (number) => (number.toFixed(2)); export let format = (number) => (number.toFixed(2));

@ -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 ```sv
{#each items as { id, name, qty }, i (id)} {#each items as {id, name, qty}, i (id)}
<li>{i + 1}: {name} x {qty}</li> <li>{i + 1}: {name} x {qty}</li>
{/each} {/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}
``` ```
--- ---
@ -1351,4 +1358,4 @@ The `<svelte:options>` element provides a place to specify per-component compile
```html ```html
<svelte:options tag="my-custom-element"/> <svelte:options tag="my-custom-element"/>
``` ```

Loading…
Cancel
Save