From 2fe919cc5e00ac17188558a0fbe93b9fa8a7d47a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Sun, 13 Jan 2019 15:06:29 +0100 Subject: [PATCH] Embed the default templates --- src/main.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index c0f40d82..a1c5a2b2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -331,17 +331,25 @@ pub struct Config { fn load_templates(path: String) -> Handlebars { 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?) - hb.register_template_string("tpl_1", "Good afternoon, {{name}}") - .unwrap(); + reg!("email_invite_accepted"); + 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 // Use .hbs extension for the files // Templates get registered with their relative name hb.register_templates_directory(".hbs", path).unwrap(); - // println!("{}", hb.render("tpl_1", &json!({"name": "Dani"})).unwrap()); - hb }