mirror of
https://github.com/dani-garcia/vaultwarden
synced 2024-12-15 01:53:43 +01:00
Embed the default templates
This commit is contained in:
parent
bcd750695f
commit
2fe919cc5e
1 changed files with 12 additions and 4 deletions
16
src/main.rs
16
src/main.rs
|
@ -331,17 +331,25 @@ pub struct Config {
|
||||||
fn load_templates(path: String) -> Handlebars {
|
fn load_templates(path: String) -> Handlebars {
|
||||||
let mut hb = Handlebars::new();
|
let mut hb = Handlebars::new();
|
||||||
|
|
||||||
|
macro_rules! reg {
|
||||||
|
($name:expr) => {
|
||||||
|
let template = include_str!(concat!("static/templates/", $name, ".hbs"));
|
||||||
|
hb.register_template_string($name, template).unwrap();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// First register default templates here (use include_str?)
|
// First register default templates here (use include_str?)
|
||||||
hb.register_template_string("tpl_1", "Good afternoon, {{name}}")
|
reg!("email_invite_accepted");
|
||||||
.unwrap();
|
reg!("email_invite_confirmed");
|
||||||
|
reg!("email_pw_hint_none");
|
||||||
|
reg!("email_pw_hint_some");
|
||||||
|
reg!("email_send_org_invite");
|
||||||
|
|
||||||
// And then load user templates to overwrite the defaults
|
// And then load user templates to overwrite the defaults
|
||||||
// Use .hbs extension for the files
|
// Use .hbs extension for the files
|
||||||
// Templates get registered with their relative name
|
// Templates get registered with their relative name
|
||||||
hb.register_templates_directory(".hbs", path).unwrap();
|
hb.register_templates_directory(".hbs", path).unwrap();
|
||||||
|
|
||||||
// println!("{}", hb.render("tpl_1", &json!({"name": "Dani"})).unwrap());
|
|
||||||
|
|
||||||
hb
|
hb
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue