From 7abef48cf2e752f06ccdc3c9148a67678420d4eb Mon Sep 17 00:00:00 2001 From: giles Date: Sat, 21 Feb 2026 09:42:58 +0000 Subject: [PATCH] Add count param to cart mini macro for explicit override When the macro is imported without context ({% from ... import mini %}), template variables like cart_count aren't visible. The new count param allows callers to pass it explicitly. Co-Authored-By: Claude Opus 4.6 --- browser/templates/_types/cart/_mini.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/browser/templates/_types/cart/_mini.html b/browser/templates/_types/cart/_mini.html index b5ae6d4..390755c 100644 --- a/browser/templates/_types/cart/_mini.html +++ b/browser/templates/_types/cart/_mini.html @@ -1,9 +1,12 @@ -{% macro mini(oob=False) %} +{% macro mini(oob=False, count=None) %}
{# cart_count is set by the context processor in all apps. Cart app computes it from g.cart + calendar_cart_entries; - other apps get it from the cart internal API. #} - {% if cart_count is defined and cart_count is not none %} + other apps get it from the cart internal API. + count param allows explicit override when macro is imported without context. #} + {% if count is not none %} + {% set _count = count %} + {% elif cart_count is defined and cart_count is not none %} {% set _count = cart_count %} {% elif cart is defined and cart is not none %} {% set _count = (cart | sum(attribute="quantity")) + ((calendar_cart_entries | length) if calendar_cart_entries else 0) %}