feat: add minijinja as template engine

This commit is contained in:
Alexander Navarro 2025-02-14 11:29:03 -03:00
parent 5a9b871e42
commit 6cb75aa442
10 changed files with 150 additions and 31 deletions

View file

@ -1,3 +1,28 @@
mod error;
pub mod router;
pub use error::{Error, Result, ResultTemplate};
use minijinja::{Environment, Template};
use serde::{Deserialize, Serialize};
use std::sync::Arc;
#[derive(Serialize, Deserialize, Debug)]
pub struct Link {
pub path: String,
pub text: String,
pub subpages: Vec<Self>,
}
pub struct AppState {
tmpl_env: Environment<'static>,
}
impl AppState {
pub fn new(tmpl_env: Environment<'static>) -> Arc<Self> {
Arc::new(AppState { tmpl_env })
}
pub fn get_template(&self, name: &str) -> Result<Template> {
Ok(self.tmpl_env.get_template(name)?)
}
}