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