Skip to content

Commit

Permalink
Add documentation for optional attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyvion committed Jul 23, 2020
1 parent c99c69e commit e229f0e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/concepts/html/elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,21 @@ html! {
{% endtab %}
{% endtabs %}

## Optional attributes for HTML elements

Most HTML attributes can be marked as optional by placing a `?` in front of
the `=` sign. This makes them accept the same type of value as otherwise, but
wrapped in an `Option<T>`:
```rust
let maybe_id = Some("foobar");

html! {
<div id?=maybe_id></div>
}
```
If the attribute is set to a `None` value, it will behave as though the
attribute wasn't set.

## Classes

There are a number of convenient options for specifying classes for an element:
Expand Down

0 comments on commit e229f0e

Please sign in to comment.