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

17
src/router.rs Normal file
View file

@ -0,0 +1,17 @@
use axum::{extract::State, response::Html, routing::get, Router};
use minijinja::context;
use std::sync::Arc;
use crate::{AppState, ResultTemplate};
pub fn new() -> Router<Arc<AppState>> {
Router::new().route("/", get(handler_home))
}
async fn handler_home(State(state): State<Arc<AppState>>) -> ResultTemplate {
let template = state.tmpl_env.get_template("base.html")?;
let content = template.render(context!())?;
Ok(Html(content))
}