From 369b087d09cbea64591a9e9e48f27a0ad48afa30 Mon Sep 17 00:00:00 2001 From: Luca Bonavita Date: Sat, 4 May 2019 20:52:19 +0100 Subject: [PATCH] Docs: document rest in array/object destructuring in each blocks Closes #2676 --- site/content/docs/01-component-format.md | 2 +- site/content/docs/02-template-syntax.md | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/site/content/docs/01-component-format.md b/site/content/docs/01-component-format.md index ddd26670756f..050b88f5c74f 100644 --- a/site/content/docs/01-component-format.md +++ b/site/content/docs/01-component-format.md @@ -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)); diff --git a/site/content/docs/02-template-syntax.md b/site/content/docs/02-template-syntax.md index a6e17f8bc26e..db95da2794ea 100644 --- a/site/content/docs/02-template-syntax.md +++ b/site/content/docs/02-template-syntax.md @@ -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)}
  • {i + 1}: {name} x {qty}
  • {/each} + +{#each objects as {id, ...rest}} +
  • {id}
  • +{/each} +{#each items as [id, ...rest]} +
  • {id}
  • +{/each} ``` --- @@ -1351,4 +1358,4 @@ The `` element provides a place to specify per-component compile ```html -``` \ No newline at end of file +```