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 <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
{% macro mini(oob=False) %}
|
||||
{% macro mini(oob=False, count=None) %}
|
||||
<div id="cart-mini" {% if oob %}hx-swap-oob="{{oob}}"{% endif %} >
|
||||
{# 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) %}
|
||||
|
||||
Reference in New Issue
Block a user