--- title: "Conditional rendering" description: "Rendering nodes conditionally in html!" --- import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; ## If blocks To conditionally render some markup, we wrap it in an `if` block: ```rust use yew::html; html! { if true {

{ "True case" }

} }; ```
```rust use yew::html; let some_condition = true; html! { if false {

{ "True case" }

} else {

{ "False case" }

} }; ```
```rust use yew::html; let some_text = Some("text"); html! { if let Some(text) = some_text {

{ text }

} }; ```
```rust use yew::html; let some_text = Some("text"); html! { if let Some(text) = some_text {

{ text }

} else {

{ "False case" }

} }; ```