use std::sync::{Arc, RwLock};
use tera::Tera;
#[derive(Debug, Clone)]
pub struct TemplateStore {
pub templates: Arc<RwLock<Tera>>,
}
pub fn get() -> TemplateStore {
let templates_glob = crate::commons::read_env("templates", "views/**/*.html");
log::info!("Your tera html templates folder is: {}", templates_glob);
let tera = Tera::new(&templates_glob).unwrap_or_else(|e| {
panic!(
"Unable to compile templates! folder={}, error_message={:?}",
templates_glob, e
)
});
let templates = Arc::new(RwLock::new(tera));
TemplateStore { templates }
}