mirror of https://github.com/yewstack/yew
Document dynamic tag names (#1628)
* add MSRV to docs * document dynamic tag names * update dictionary * right, it dooesn't know about boolean still
This commit is contained in:
parent
fa2ab5abe7
commit
3106b7be54
|
@ -38,6 +38,7 @@ Lifecycle
|
|||
linecap
|
||||
linejoin
|
||||
memoized
|
||||
MSRV
|
||||
natively
|
||||
onclick
|
||||
proc
|
||||
|
@ -47,6 +48,7 @@ rlib
|
|||
roadmap
|
||||
Roadmap
|
||||
rollup
|
||||
rustc
|
||||
rustup
|
||||
stdweb
|
||||
struct
|
||||
|
@ -56,6 +58,7 @@ textarea
|
|||
thead
|
||||
TODO
|
||||
toml
|
||||
toolchain
|
||||
Unselected
|
||||
usize
|
||||
VecDeque
|
||||
|
|
|
@ -3,6 +3,22 @@ title: Elements
|
|||
description: Both HTML and SVG elements are supported
|
||||
---
|
||||
|
||||
## Dynamic tag names
|
||||
|
||||
When building a higher-order component you might find yourself in a situation where the element's tag name isn't static.
|
||||
For example, you might have a `Title` component which can render anything from `h1` to `h6` depending on a level prop.
|
||||
Instead of having to use a big match expression, Yew allows you to set the tag name dynamically
|
||||
using `@{name}` where `name` can be any expression that returns a string.
|
||||
|
||||
```rust
|
||||
let level = 5;
|
||||
let text = "Hello World!".to_owned()
|
||||
|
||||
html! {
|
||||
<@{format!("h{}", level)} class="title">{ content }</@>
|
||||
}
|
||||
```
|
||||
|
||||
## Optional attributes for HTML elements
|
||||
|
||||
Most HTML attributes can be marked as optional by placing a `?` in front of
|
||||
|
|
|
@ -11,6 +11,11 @@ First, you'll need Rust. To install Rust and the `cargo` build tool, follow the
|
|||
You also need to install the `wasm32-unknown-unknown` target to compile Rust to Wasm.
|
||||
If you're using rustup, you just need to run `rustup target add wasm32-unknown-unknown`.
|
||||
|
||||
:::important
|
||||
The minimum supported Rust version (MSRV) for Yew is `1.45.0`. Older versions can cause unexpected issues accompanied by incomprehensible error messages.
|
||||
You can check your toolchain version using `rustup show` (under "active toolchain") or alternatively `rustc --version`. To update your toolchain, run `rustup update`.
|
||||
:::
|
||||
|
||||
## **Wasm Build Tools**
|
||||
|
||||
Extra tooling is needed to facilitate the interop between WebAssembly and JavaScript. Additionally,
|
||||
|
|
Loading…
Reference in New Issue