From 95094a7d509c8a106db592dcefe53e05b0e4d326 Mon Sep 17 00:00:00 2001 From: Paul van Tilburg Date: Fri, 9 Mar 2018 22:24:33 +0100 Subject: [PATCH] Replace the hardcoded title in the template by the one in the config --- src/handlers/home.rs | 5 ++++- templates/_layout.html.tera | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/handlers/home.rs b/src/handlers/home.rs index d88bac3..8fc864a 100644 --- a/src/handlers/home.rs +++ b/src/handlers/home.rs @@ -1,16 +1,18 @@ use rocket::State; use rocket_contrib::Template; use std::collections::HashMap; +use super::super::Config; use super::super::NoteStore; #[derive(Serialize)] struct IndexTemplateContext<'a> { app_version: &'a str, notes: Vec>, + title: String, } #[get("/")] -fn index(notes: State) -> Template { +fn index(notes: State, config: State) -> Template { let notes = notes.read().unwrap(); let mut note_kvs = vec![]; for note in notes.iter() { @@ -22,6 +24,7 @@ fn index(notes: State) -> Template { let context = IndexTemplateContext { app_version: env!("CARGO_PKG_VERSION"), notes: note_kvs, + title: config.title.clone(), }; Template::render("index", &context) } diff --git a/templates/_layout.html.tera b/templates/_layout.html.tera index 40fc1da..fd5c69a 100644 --- a/templates/_layout.html.tera +++ b/templates/_layout.html.tera @@ -5,7 +5,7 @@ - {% block title %}Online Prikbord Familie van Tilburg{% endblock title %} + {% block title %}{{ title }}{% endblock title %} @@ -34,7 +34,7 @@ {% block body %}