use global config
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending
ci/woodpecker/pr/publish Pipeline is pending

This commit is contained in:
Mylloon 2023-04-11 01:08:07 +02:00
parent ff7fa90cdc
commit 46ced07b2a
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 13 additions and 2 deletions

View file

@ -86,10 +86,11 @@ pub fn get_config(file_path: &str) -> Config {
); );
Config { Config {
fc: internal_config, fc: internal_config.clone(),
static_location: format!("{}/{}", files_root, static_dir), static_location: format!("{}/{}", files_root, static_dir),
tmpl: Template { tmpl: Template {
directory: format!("{}/{}", files_root, templates_dir), directory: format!("{}/{}", files_root, templates_dir),
app_name: internal_config.app_name.unwrap(),
}, },
} }
} }

View file

@ -4,6 +4,13 @@ use serde::Deserialize;
#[derive(Clone)] #[derive(Clone)]
pub struct Template { pub struct Template {
pub directory: String, pub directory: String,
pub app_name: String,
}
#[derive(Content)]
struct Data<T> {
app_name: String,
data: T,
} }
impl Template { impl Template {
@ -11,7 +18,10 @@ impl Template {
let mut templates: Ramhorns = Ramhorns::lazy(&self.directory).unwrap(); let mut templates: Ramhorns = Ramhorns::lazy(&self.directory).unwrap();
let tplt = templates.from_file(template).unwrap(); let tplt = templates.from_file(template).unwrap();
tplt.render(&data) tplt.render(&Data {
app_name: self.app_name.clone(),
data,
})
} }
} }