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:
Simon 2020-10-21 16:07:29 +02:00 committed by GitHub
parent fa2ab5abe7
commit 3106b7be54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 0 deletions

View File

@ -38,6 +38,7 @@ Lifecycle
linecap linecap
linejoin linejoin
memoized memoized
MSRV
natively natively
onclick onclick
proc proc
@ -47,6 +48,7 @@ rlib
roadmap roadmap
Roadmap Roadmap
rollup rollup
rustc
rustup rustup
stdweb stdweb
struct struct
@ -56,6 +58,7 @@ textarea
thead thead
TODO TODO
toml toml
toolchain
Unselected Unselected
usize usize
VecDeque VecDeque

View File

@ -3,6 +3,22 @@ title: Elements
description: Both HTML and SVG elements are supported 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 ## Optional attributes for HTML elements
Most HTML attributes can be marked as optional by placing a `?` in front of Most HTML attributes can be marked as optional by placing a `?` in front of

View File

@ -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. 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`. 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** ## **Wasm Build Tools**
Extra tooling is needed to facilitate the interop between WebAssembly and JavaScript. Additionally, Extra tooling is needed to facilitate the interop between WebAssembly and JavaScript. Additionally,