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/statistics.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'src/controller/statistics.rs') diff --git a/src/controller/statistics.rs b/src/controller/statistics.rs index eb1e704..e57e2be 100644 --- a/src/controller/statistics.rs +++ b/src/controller/statistics.rs @@ -1,7 +1,6 @@ use http_body_util::Full; use hyper::body::Bytes; use hyper::Response; -use tera::Context; use crate::controller::utils; use crate::controller::wallet::Wallet; @@ -13,15 +12,13 @@ pub async fn get(wallet: &Wallet) -> Response> { let payments = db::payments::list_for_stats(&wallet.pool).await; let incomes = db::incomes::total_each_month(&wallet.pool).await; - let mut context = Context::new(); - context.insert("header", &templates::Header::Statistics); - context.insert("connected_user", &wallet.user); - context.insert( - "json_categories", - &serde_json::to_string(&categories).unwrap(), + let context = minijinja::context!( + header => templates::Header::Statistics, + connected_user => wallet.user, + json_categories => serde_json::to_string(&categories).unwrap(), + json_payments => serde_json::to_string(&payments).unwrap(), + json_incomes => serde_json::to_string(&incomes).unwrap() ); - context.insert("json_payments", &serde_json::to_string(&payments).unwrap()); - context.insert("json_incomes", &serde_json::to_string(&incomes).unwrap()); utils::template( &wallet.assets, -- cgit v1.2.3