Skip to content

Commit cf66986

Browse files
authored
Document debug tags
1 parent 429e549 commit cf66986

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

content/guide/02-template-syntax.md

+27-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ If the expression in `{#await expression}` *isn't* a promise, Svelte skips ahead
267267

268268
### Directives
269269

270-
The last place where Svelte template syntax differs from regular HTML: *directives* allow you to add special instructions for adding [event handlers](guide#event-handlers), [bindings](guide#bindings), [referencing elements](guide#refs) and so on. We'll cover each of those in later stages of this guide – for now, all you need to know is that directives can be identified by the `:` character:
270+
Directives allow you to add special instructions for adding [event handlers](guide#event-handlers), [bindings](guide#bindings), [referencing elements](guide#refs) and so on. We'll cover each of those in later stages of this guide – for now, all you need to know is that directives can be identified by the `:` character:
271271

272272
```html
273273
<!--{ title: 'Element directives' }-->
@@ -283,3 +283,29 @@ The last place where Svelte template syntax differs from regular HTML: *directiv
283283
```
284284

285285
> Technically, the `:` character is used to denote namespaced attributes in HTML. These will *not* be treated as directives, if encountered.
286+
287+
288+
### Debug tags
289+
290+
To inspect data as it changes and flows through your app, use a `{@debug ...}` tag:
291+
292+
```html
293+
<!--{ title: 'Debug tags' }-->
294+
<input bind:value=name>
295+
296+
{@debug name}
297+
<h1>Hello {name}!</h1>
298+
```
299+
300+
```json
301+
/* { hidden: true } */
302+
{
303+
name: 'world'
304+
}
305+
```
306+
307+
This will log the value of `name` whenever it changes. If your devtools are open, changing `name` will pause execution and open the debugger.
308+
309+
You can debug multiple values simultaneously (`{@debug foo, bar, baz}`), or use `{@debug}` to pause execution whenever the surrounding markup is updated.
310+
311+
> Debug tags only have an effect when compiling with the `dev: true` compiler option.

0 commit comments

Comments
 (0)