use global config
This commit is contained in:
parent
ff7fa90cdc
commit
46ced07b2a
2 changed files with 13 additions and 2 deletions
|
@ -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(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue