From 965669f59c53f0ce014c79844053fe33378afded Mon Sep 17 00:00:00 2001 From: tanhauhau Date: Sun, 28 Nov 2021 01:49:13 +0800 Subject: [PATCH] add section to doc --- site/content/docs/02-template-syntax.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/site/content/docs/02-template-syntax.md b/site/content/docs/02-template-syntax.md index e6db1854d2..34b0509fc1 100644 --- a/site/content/docs/02-template-syntax.md +++ b/site/content/docs/02-template-syntax.md @@ -453,6 +453,29 @@ The `{@debug ...}` tag offers an alternative to `console.log(...)`. It logs the The `{@debug}` tag without any arguments will insert a `debugger` statement that gets triggered when *any* state changes, as opposed to the specified variables. +### {@const ...} + +```sv +{@const assignment} +``` + +--- + +The `{@const ...}` tag defines a local constant. + +```sv + + +{#each boxes as box} + {@const area = box.width * box.height} + {box.width} * {box.height} = {area} +{/each} +``` + +`{@const}` is only allowed as direct child of `{#each}` block, `{#then}` and `{#catch}` block, `` and `` element. + ### Element directives