Skip to content

Commit

Permalink
Clearer headlines with syntax examples
Browse files Browse the repository at this point in the history
Change headline “Actions” to “Use directive” + add a number of additional syntax examples, to make it easier to find the relevant section without ⌘F
  • Loading branch information
trbrc authored Jun 1, 2019
1 parent 7105788 commit b4b9edf
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions site/content/docs/02-template-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ If you don't care about the pending state, you can also omit the initial block.
```


### DOM events
### DOM events (on:eventname)

```sv
on:eventname={handler}
Expand Down Expand Up @@ -370,7 +370,7 @@ It's possible to have multiple event listeners for the same event:
<button on:click={increment} on:click={track}>Click me!</button>
```

### Component events
### Component events (on:eventname)

```sv
on:eventname={handler}
Expand All @@ -392,7 +392,7 @@ As with DOM events, if the `on:` directive is used without a value, the componen
<SomeComponent on:whatever/>
```

### Element bindings
### Element bindings (bind:property)

```sv
bind:property={variable}
Expand Down Expand Up @@ -436,7 +436,7 @@ Numeric input values are coerced; even though `input.value` is a string as far a
<input type="range" bind:value={num}>
```

#### Binding related elements
#### Binding related elements (bind:group)

---

Expand Down Expand Up @@ -550,7 +550,7 @@ Block-level elements have 4 readonly bindings, measured using a technique simila
</div>
```

#### Binding a DOM node
#### Binding a DOM node (bind:this)

---

Expand All @@ -572,7 +572,7 @@ To get a reference to a DOM node, use `bind:this`.
```


### Component bindings
### Component bindings (bind:property)

```sv
bind:property={variable}
Expand All @@ -589,6 +589,8 @@ You can bind to component props using the same mechanism.
<Keypad bind:value={pin}/>
```

#### Binding a component instance (bind:this)

---

Components also support `bind:this`, allowing you to interact with component instances programmatically.
Expand All @@ -604,7 +606,7 @@ Components also support `bind:this`, allowing you to interact with component ins
```


### Classes
### Class directive (class:name)

```sv
class:name={value}
Expand All @@ -630,7 +632,7 @@ A `class:` directive provides a shorter way of toggling a class on an element.
```


### Actions
### Use directive (use:action)

```sv
use:action
Expand Down Expand Up @@ -695,7 +697,7 @@ An action can have parameters. If the returned value has an `update` method, it
```


### Transitions
### Transitions (transition/in/out:name)

```sv
transition:name
Expand Down Expand Up @@ -911,7 +913,7 @@ Local transitions only play when the block they belong to is created or destroye
```


### Animations
### Animations (animate:name)

```sv
animate:name
Expand Down Expand Up @@ -1047,7 +1049,7 @@ A custom animation function can also return a `tick` function, which is called *



### Slots
### &lt;slot&gt;

```sv
<slot><!-- optional fallback --></slot>
Expand Down Expand Up @@ -1079,6 +1081,8 @@ The content is exposed in the child component using the `<slot>` element, which
</div>
```

#### Named slots (slot="name")

---

Named slots allow consumers to target specific areas. They can also have fallback content.
Expand All @@ -1098,6 +1102,8 @@ Named slots allow consumers to target specific areas. They can also have fallbac
</div>
```

#### Let directive (let:name)

---

Slots can be rendered zero or more times, and can pass values *back* to the parent using props. The parent exposes the values to the slot template using the `let:` directive.
Expand Down Expand Up @@ -1325,4 +1331,4 @@ It accepts a comma-separated list of variable names (not arbitrary expressions).
{@debug typeof user === 'object'}
```

The `{@debug}` tag without any arguments will insert a `debugger` statement that gets triggered when *any* state changes, as opposed to the specified variables.
The `{@debug}` tag without any arguments will insert a `debugger` statement that gets triggered when *any* state changes, as opposed to the specified variables.

0 comments on commit b4b9edf

Please sign in to comment.