yew/website/docs/concepts/html/fragments.mdx
Johannes Sjölund 9556266061
Improve grammar in website/docs (#3092)
* Improve grammar in website/docs

* Futuresolo's changes to website/docs
2023-02-01 22:21:31 +05:00

44 lines
601 B
Plaintext

---
title: 'Fragments'
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
The `html!` macro always requires a single root node. To get around this restriction, you
can use an "empty tag" (these are also called "fragments").
<Tabs>
<TabItem value="Valid" label="Valid">
```rust
use yew::prelude::*;
html! {
<>
<div></div>
<p></p>
</>
};
```
</TabItem>
<TabItem value="Invalid" label="Invalid">
```rust, compile_fail
use yew::prelude::*;
// error: only one root html element allowed
html! {
<div></div>
<p></p>
};
```
</TabItem>
</Tabs>