diff options
author | Joris | 2025-01-26 17:58:57 +0100 |
---|---|---|
committer | Joris | 2025-01-26 17:58:57 +0100 |
commit | 24eeb54a6b7159964e8887ade7fa5173b50feb3a (patch) | |
tree | 91af6253df784445db9b084b02b38b37a83224e8 /src/controller/categories.rs | |
parent | c5759f348e70cf54b4bfa4cd17e1fe1828ead30a (diff) |
Replace tera by minijinjamain
tera was doing the job all right, but minijinja has fewer dependencies.
Diffstat (limited to 'src/controller/categories.rs')
-rw-r--r-- | src/controller/categories.rs | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/src/controller/categories.rs b/src/controller/categories.rs index ff2d8e7..fbbd309 100644 --- a/src/controller/categories.rs +++ b/src/controller/categories.rs @@ -2,7 +2,6 @@ use http_body_util::Full; use hyper::body::Bytes; use hyper::Response; use std::collections::HashMap; -use tera::Context; use crate::controller::utils; use crate::controller::wallet::Wallet; @@ -17,11 +16,12 @@ pub async fn table( ) -> Response<Full<Bytes>> { let categories = db::categories::list(&wallet.pool).await; - let mut context = Context::new(); - context.insert("header", &templates::Header::Categories); - context.insert("connected_user", &wallet.user); - context.insert("categories", &categories); - context.insert("highlight", &query.highlight); + let context = minijinja::context!( + header => templates::Header::Categories, + connected_user => wallet.user, + categories => categories, + highlight => query.highlight + ); utils::template( &wallet.assets, @@ -40,11 +40,12 @@ async fn create_form_feedback( form: HashMap<String, String>, error: Option<String>, ) -> Response<Full<Bytes>> { - let mut context = Context::new(); - context.insert("header", &templates::Header::Categories); - context.insert("connected_user", &wallet.user.clone()); - context.insert("form", &form); - context.insert("error", &error); + let context = minijinja::context!( + header => &templates::Header::Categories, + connected_user => &wallet.user.clone(), + form => &form, + error => &error + ); utils::template( &wallet.assets, @@ -89,14 +90,15 @@ async fn update_form_feedback( let is_category_used = db::payments::is_category_used(&wallet.pool, id).await; - let mut context = Context::new(); - context.insert("header", &templates::Header::Categories); - context.insert("connected_user", &wallet.user); - context.insert("id", &id); - context.insert("category", &category); - context.insert("is_category_used", &is_category_used); - context.insert("form", &form); - context.insert("error", &error); + let context = minijinja::context!( + header => templates::Header::Categories, + connected_user => wallet.user, + id => id, + category => category, + is_category_used => is_category_used, + form => form, + error => error + ); utils::template( &wallet.assets, |