From 24eeb54a6b7159964e8887ade7fa5173b50feb3a Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 26 Jan 2025 17:58:57 +0100 Subject: Replace tera by minijinja tera was doing the job all right, but minijinja has fewer dependencies. --- src/controller/balance.rs | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src/controller/balance.rs') diff --git a/src/controller/balance.rs b/src/controller/balance.rs index c5d9d4a..efe5af6 100644 --- a/src/controller/balance.rs +++ b/src/controller/balance.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; @@ -31,18 +30,16 @@ pub async fn get(wallet: &Wallet) -> Response> { let exceeding_payers = payer::exceeding(&users, &user_incomes, &user_payments); - let mut context = Context::new(); - context.insert("header", &templates::Header::Balance); - context.insert("connected_user", &wallet.user); - context.insert( - "incomes_from", - &incomes_from.map(|d| d.format("%d/%m/%Y").to_string()), + let context = minijinja::context!( + header => templates::Header::Balance, + connected_user => wallet.user, + incomes_from => incomes_from.map(|d| d.format("%d/%m/%Y").to_string()), + total_income => total_income, + user_incomes => template_user_incomes, + total_payments => total_payments, + user_payments => template_user_payments, + exceeding_payers => exceeding_payers ); - context.insert("total_income", &total_income); - context.insert("user_incomes", &template_user_incomes); - context.insert("total_payments", &total_payments); - context.insert("user_payments", &template_user_payments); - context.insert("exceeding_payers", &exceeding_payers); utils::template(&wallet.assets, &wallet.templates, "balance.html", context) } -- cgit v1.2.3