From 46ced07b2a759b8541781fe59fad91e3eac77fd6 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Tue, 11 Apr 2023 01:08:07 +0200 Subject: [PATCH] use global config --- src/config.rs | 3 ++- src/template.rs | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index ba92d08..429efef 100644 --- a/src/config.rs +++ b/src/config.rs @@ -86,10 +86,11 @@ pub fn get_config(file_path: &str) -> Config { ); Config { - fc: internal_config, + fc: internal_config.clone(), static_location: format!("{}/{}", files_root, static_dir), tmpl: Template { directory: format!("{}/{}", files_root, templates_dir), + app_name: internal_config.app_name.unwrap(), }, } } diff --git a/src/template.rs b/src/template.rs index b0d7c49..ed154ab 100644 --- a/src/template.rs +++ b/src/template.rs @@ -4,6 +4,13 @@ use serde::Deserialize; #[derive(Clone)] pub struct Template { pub directory: String, + pub app_name: String, +} + +#[derive(Content)] +struct Data { + app_name: String, + data: T, } impl Template { @@ -11,7 +18,10 @@ impl Template { let mut templates: Ramhorns = Ramhorns::lazy(&self.directory).unwrap(); let tplt = templates.from_file(template).unwrap(); - tplt.render(&data) + tplt.render(&Data { + app_name: self.app_name.clone(), + data, + }) } }