aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2019-03-03 10:41:22 +0100
committerHarald Eilertsen <haraldei@anduin.net>2019-03-03 10:41:22 +0100
commitecc0ff7bf3f05ce11f59ce25f5c262905d594b9b (patch)
tree0b24bca7d6c13876a47d85264ceb71fb137e0472
parent84a0b65e73c1cbaf032b533de2236b0c09eb310b (diff)
downloadramaskrik-social-ecc0ff7bf3f05ce11f59ce25f5c262905d594b9b.tar.gz
ramaskrik-social-ecc0ff7bf3f05ce11f59ce25f5c262905d594b9b.tar.bz2
ramaskrik-social-ecc0ff7bf3f05ce11f59ce25f5c262905d594b9b.zip
Enable askama rocket integration.
Let's us return templates directly, and have rocket render it for us.
-rw-r--r--Cargo.lock1
-rw-r--r--Cargo.toml2
-rw-r--r--src/main.rs10
3 files changed, 5 insertions, 8 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 34d00be..d10178d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6,6 +6,7 @@ dependencies = [
"askama_derive 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"askama_escape 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"askama_shared 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rocket 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
diff --git a/Cargo.toml b/Cargo.toml
index 39e1253..1e03f2a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,5 +5,5 @@ authors = ["haraldei"]
edition = "2018"
[dependencies]
-askama = "0.8.0"
+askama = { version = "0.8.0", features = ["with-rocket"] }
rocket = "0.4.0"
diff --git a/src/main.rs b/src/main.rs
index 307bbc4..1ee6011 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -22,10 +22,7 @@ use rocket::{
get,
http::RawStr,
routes,
- response::{
- NamedFile,
- content::Html,
- },
+ response::NamedFile,
};
use std::path::PathBuf;
@@ -36,9 +33,8 @@ struct IndexTemplate<'a> {
}
#[get("/")]
-fn index<'a>() -> Html<String> {
- let t = IndexTemplate { year: "2019" };
- Html(t.render().unwrap())
+fn index<'a>() -> IndexTemplate<'static> {
+ IndexTemplate { year: "2019" }
}
#[get("/<file>", rank = 99)]