Rocket example.
This commit is contained in:
parent
cc8e7219a2
commit
ca77a12599
|
@ -2,5 +2,6 @@
|
|||
members = [
|
||||
"typed-html",
|
||||
"macros",
|
||||
"wasm"
|
||||
"wasm",
|
||||
"rocket"
|
||||
]
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "typed-html-rocket-test"
|
||||
version = "0.1.0"
|
||||
authors = ["Bodil Stokke <bodil@bodil.org>"]
|
||||
|
||||
[dependencies]
|
||||
typed-html-macros = { path = "../macros" }
|
||||
typed-html = { path = "../typed-html" }
|
||||
rocket = "0.4.0-rc.1"
|
|
@ -0,0 +1,41 @@
|
|||
#![feature(proc_macro_hygiene, decl_macro, try_from)]
|
||||
|
||||
extern crate rocket;
|
||||
extern crate typed_html;
|
||||
extern crate typed_html_macros;
|
||||
|
||||
use rocket::http::ContentType;
|
||||
use rocket::response::Content;
|
||||
use rocket::{get, routes};
|
||||
use typed_html::text;
|
||||
use typed_html::types::LinkType;
|
||||
use typed_html_macros::html;
|
||||
|
||||
#[get("/")]
|
||||
fn index() -> Content<String> {
|
||||
Content(ContentType::HTML, html!(
|
||||
<html>
|
||||
<head>
|
||||
<title>"Hello Kitty!"</title>
|
||||
<link rel=LinkType::StyleSheet href="lol.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<h1 data-lol="omg">"Hello Kitty!"</h1>
|
||||
<p class="official-position-of-sanrio-ltd">
|
||||
"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 class=["urgent", "question"]>"But how does she eat?"</p>
|
||||
{
|
||||
(1..4).map(|i| {
|
||||
html!(<p>{ text!("{}. Ceci n'est pas une chatte.", i) }</p>)
|
||||
})
|
||||
}
|
||||
<p>"<img src=\"javascript:alert('pwned lol')\">"</p>
|
||||
</body>
|
||||
</html>
|
||||
).to_string())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
rocket::ignite().mount("/", routes![index]).launch();
|
||||
}
|
Loading…
Reference in New Issue