Move optional attribute documentation ()

This commit is contained in:
Chris Wong 2023-02-13 12:34:34 +11:00 committed by GitHub
parent 4f14db7415
commit cdb9d3a48d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 19 deletions

View file

@ -84,25 +84,6 @@ html! {
# ;
```
## Optional attributes: `title=[Some("value")]`
Add optional attributes to an element using `attr=[value]` syntax, with *square* brackets.
These are only rendered if the value is `Some<T>`, and entirely omitted if the value is `None`.
```rust
# let _ = maud::
html! {
p title=[Some("Good password")] { "Correct horse" }
@let value = Some(42);
input value=[value];
@let title: Option<&str> = None;
p title=[title] { "Battery staple" }
}
# ;
```
## Empty attributes: `checked`
Declare an empty attribute by omitting the value.

View file

@ -142,3 +142,22 @@ html! {
}
# ;
```
### Optional attributes with values: `title=[Some("value")]`
Add optional attributes to an element using `attr=[value]` syntax, with *square* brackets.
These are only rendered if the value is `Some<T>`, and entirely omitted if the value is `None`.
```rust
# let _ = maud::
html! {
p title=[Some("Good password")] { "Correct horse" }
@let value = Some(42);
input value=[value];
@let title: Option<&str> = None;
p title=[title] { "Battery staple" }
}
# ;
```