docs: improve components and elements

This commit is contained in:
Jonathan Kelley committed 2022-01-09 22:28:07 -05:00
1 parent 5b882ac409
commit bdf234d728
9 files changed
+267 -57

No files matched your search

+3 -3
View File
@@ -81,13 +81,13 @@ let name = "Bob";
rsx! ( "hello {name}" )
```
Unfortunately, you cannot drop in arbitrary expressions directly into the string literal. In the cases where we need to compute a complex value, we'll want to use `format_args!` directly. Due to specifics of how the `rsx!` macro (we'll cover later), our call to `format_args` must be contained within curly braces *and* square braces.
Unfortunately, you cannot drop in arbitrary expressions directly into the string literal. In the cases where we need to compute a complex value, we'll want to use `format_args!` directly. Due to specifics of how the `rsx!` macro (we'll cover later), our call to `format_args` must be contained within square braces.
```rust
rsx!( {[format_args!("Hello {}", if enabled { "Jack" } else { "Bob" } )]} )
rsx!( {format_args!("Hello {}", if enabled { "Jack" } else { "Bob" } )] )
```
Alternatively, `&str` can be included directly, though it must be inside of an array:
Alternatively, `&str` can be included directly, though it must be inside of square braces:
```rust
rsx!( "Hello ", [if enabled { "Jack" } else { "Bob" }] )