From ca77a125990434a6d3881419e99168366e260a66 Mon Sep 17 00:00:00 2001 From: Bodil Stokke Date: Wed, 14 Nov 2018 19:00:29 +0000 Subject: [PATCH] Rocket example. --- Cargo.toml | 3 ++- rocket/Cargo.toml | 9 +++++++++ rocket/src/main.rs | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 rocket/Cargo.toml create mode 100644 rocket/src/main.rs diff --git a/Cargo.toml b/Cargo.toml index 02a6d72..a9cc6a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,5 +2,6 @@ members = [ "typed-html", "macros", - "wasm" + "wasm", + "rocket" ] diff --git a/rocket/Cargo.toml b/rocket/Cargo.toml new file mode 100644 index 0000000..bfdf3ec --- /dev/null +++ b/rocket/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "typed-html-rocket-test" +version = "0.1.0" +authors = ["Bodil Stokke "] + +[dependencies] +typed-html-macros = { path = "../macros" } +typed-html = { path = "../typed-html" } +rocket = "0.4.0-rc.1" diff --git a/rocket/src/main.rs b/rocket/src/main.rs new file mode 100644 index 0000000..8cf8a29 --- /dev/null +++ b/rocket/src/main.rs @@ -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 { + Content(ContentType::HTML, html!( + + + "Hello Kitty!" + + + +

"Hello Kitty!"

+

+ "She is not a ""cat"". She is a ""human girl""." +

+

"But how does she eat?"

+ { + (1..4).map(|i| { + html!(

{ text!("{}. Ceci n'est pas une chatte.", i) }

) + }) + } +

""

+ + + ).to_string()) +} + +fn main() { + rocket::ignite().mount("/", routes![index]).launch(); +}