12345678910111213141516171819202122 |
- use lazy_static::lazy_static;
- use tera::{Context, Tera};
- use tide::Result;
-
- lazy_static! {
- pub static ref TEMPLATES: Tera = {
- let mut tera = match Tera::new("templates/**/*.html") {
- Ok(t) => t,
- Err(e) => {
- println!("Parsing error(s): {}", e);
- ::std::process::exit(1);
- }
- };
- tera.autoescape_on(vec!["html", ".sql"]);
- tera
- };
- }
-
- pub fn render_template(template: &str, context: &Context) -> Result<String> {
- let html = TEMPLATES.render(template, &context)?;
- Ok(html)
- }
|