-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathmain.rs
31 lines (28 loc) · 885 Bytes
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#![recursion_limit = "256"]
extern crate stdweb;
extern crate typed_html;
use stdweb::web::{self, INode};
use typed_html::dom::Node;
use typed_html::html;
use typed_html::output::stdweb::Stdweb;
fn main() {
let mut doc = html!(
<div role="main">
<h1>"Hello Kitty"</h1>
<p>
"She is not a "<em><a href="https://en.wikipedia.org/wiki/Cat">"cat"</a></em>
". She is a "<em>"human girl"</em>"."
</p>
<p>
<button onclick={ |_event| web::alert("Hello Joe!") }>
"Call Joe"
</button>
</p>
</div>
: Stdweb);
let vdom = doc.vnode();
let document = web::document();
let body = document.body().expect("no body element in doc");
let tree = Stdweb::build(&document, vdom).unwrap();
body.append_child(&tree);
}