aboutsummaryrefslogtreecommitdiffstats
path: root/src/controllers/home_controller.rs
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2018-01-14 12:39:50 +0100
committerHarald Eilertsen <haraldei@anduin.net>2018-01-14 12:39:50 +0100
commit0dae37a2e98c13fbc78acd58b86565fd6f14c654 (patch)
tree681be6b03971acca3f57fd30d613909b60aaa984 /src/controllers/home_controller.rs
parenta77f6e9d27f98bc36d0911ce58c109f4a18bd835 (diff)
downloadrocket-blog-0dae37a2e98c13fbc78acd58b86565fd6f14c654.tar.gz
rocket-blog-0dae37a2e98c13fbc78acd58b86565fd6f14c654.tar.bz2
rocket-blog-0dae37a2e98c13fbc78acd58b86565fd6f14c654.zip
Split out layout from templates.
Diffstat (limited to 'src/controllers/home_controller.rs')
-rw-r--r--src/controllers/home_controller.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/controllers/home_controller.rs b/src/controllers/home_controller.rs
index c4c0c56..563be40 100644
--- a/src/controllers/home_controller.rs
+++ b/src/controllers/home_controller.rs
@@ -3,16 +3,20 @@ use rocket_contrib::Json;
#[derive(BartDisplay, Serialize)]
#[template = "templates/index.html"]
-struct IndexTemplate<'a> {
- title: &'a str,
+struct IndexTemplate {
posts: Vec<models::Post>
}
-implement_responder_for!(IndexTemplate<'a>);
+implement_responder_for!(IndexTemplate);
#[get("/", format = "text/html")]
-fn index<'a>(conn: utils::DbConn) -> IndexTemplate<'a> {
- IndexTemplate { title: "Bloggen", posts: models::Post::get_all(conn) }
+fn index(conn: utils::DbConn) -> utils::Page<IndexTemplate> {
+ utils::Page {
+ title: String::from("Bloggen"),
+ content: IndexTemplate {
+ posts: models::Post::get_all(conn)
+ }
+ }
}
#[get("/", format = "application/json")]