Skip to content

Commit

Permalink
Add iterable children and comments to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chinedufn authored Jan 28, 2019
1 parent e642117 commit 5260e11
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions book/src/html-macro/html-macro.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ let parent_view = html! {
<div>
{ view1 }
{ view2 }
html! {
Nested html! call
{
html! {
Nested html! call
}
}
</div>
};
Expand All @@ -73,3 +75,38 @@ let html_string = parent_view.to_string();
// Here's what the String looks like:
// <div><em></em><span></span>Nested html! call</div>
```

### Iterable Children

Any type that implements IntoIter<VirtualNode> can be used as a child element within a block.

```rust
let list = vec!["1", "2", "3"]
.map(|item_num| {
html! {
<li>
List item number { text!(item_num) }
</li>
}
});

html! {
<ul> { list } >/ul>
}
```

### Comments

You can use Rust comments within your HTML

```rust
html! {
/* Main Div */
<div>
<br />
// Title
<h2>Header</h2>
<br />
</div>
}
```

0 comments on commit 5260e11

Please sign in to comment.