yew/docs/concepts/html/lists.md
Teymour Aldridge b9863c1f5c
Finish setup of docusaurus (#1423)
* Add links to the sidebar.

* Remove unnecessary `page-ref`s (these links are now in the sidebar).

* Small grammar/style fix.

* Fix code tabs.

* Remove {% page-ref %} uses.

* Fix some line lengths.

* Split out `custom.css` into multiple files.

* Remove duplicate titles.
2020-07-24 16:17:47 +02:00

881 B

id title
lists Lists

Fragments

The html! macro always requires a single root node. In order to get around this restriction, it's valid to wrap content in empty tags:

html! {
    <>
        <div></div>
        <p></p>
    </>
}
/* error: only one root html element allowed */

html! {
    <div></div>
    <p></p>
}

Iterators

Yew supports two different syntaxes for building html from an iterator:

html! {
    <ul class="item-list">
        { self.props.items.iter().map(renderItem).collect::<Html>() }
    </ul>
}
html! {
    <ul class="item-list">
        { for self.props.items.iter().map(renderItem) }
    </ul>
}