aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2019-03-02 23:26:58 +0100
committerHarald Eilertsen <haraldei@anduin.net>2019-03-02 23:26:58 +0100
commit5f1b9f03525706a45c202b70912f7ff2e6d77fee (patch)
tree228939a6d015fbd9f5a3bb77bb6a9b984ffe2eb9 /src
parent50adf72a2391bbd840eb139a5f82e503530c65fb (diff)
downloadramaskrik-social-5f1b9f03525706a45c202b70912f7ff2e6d77fee.tar.gz
ramaskrik-social-5f1b9f03525706a45c202b70912f7ff2e6d77fee.tar.bz2
ramaskrik-social-5f1b9f03525706a45c202b70912f7ff2e6d77fee.zip
Use askama for templates.
Diffstat (limited to 'src')
-rw-r--r--src/main.rs22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/main.rs b/src/main.rs
index f97f600..042465d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,11 +1,27 @@
#![feature(proc_macro_hygiene, decl_macro)]
-use rocket::{get, http::RawStr, routes, response::NamedFile};
+use askama::Template;
+use rocket::{
+ get,
+ http::RawStr,
+ routes,
+ response::{
+ NamedFile,
+ content::Html,
+ },
+};
use std::path::PathBuf;
+#[derive(Template)]
+#[template(path = "index.html")]
+struct IndexTemplate<'a> {
+ year: &'a str,
+}
+
#[get("/")]
-fn index() -> &'static str {
- "Holahey, Jävlar!"
+fn index<'a>() -> Html<String> {
+ let t = IndexTemplate { year: "2019" };
+ Html(t.render().unwrap())
}
#[get("/<file>", rank = 99)]