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 {
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(),
},
}
}

View file

@ -4,6 +4,13 @@ use serde::Deserialize;
#[derive(Clone)]
pub struct Template {
pub directory: String,
pub app_name: String,
}
#[derive(Content)]
struct Data<T> {
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,
})
}
}