From 8c4adaad1f3b1d22c6f43f1f0e1fce8bfa9c7b30 Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Tue, 3 Oct 2017 11:28:05 +0200 Subject: [PATCH] modified filter box macro to add multiple boxes on one page --- development.ini | 5 +++++ ordr2/templates/macros.jinja2 | 14 +++++++++----- ordr2/templates/tests.py | 4 ++++ 3 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 ordr2/templates/tests.py diff --git a/development.ini b/development.ini index cb20cc3..bd0108c 100644 --- a/development.ini +++ b/development.ini @@ -33,6 +33,11 @@ session.secret = 'Change Me 2' session.auto_csrf = true static_views.cache_max_age = 0 +# custom jinja filters and tests +jinja2.filters = + are_extras_active = ordr2.templates.tests:are_extras_active + + ### # wsgi server configuration ### diff --git a/ordr2/templates/macros.jinja2 b/ordr2/templates/macros.jinja2 index 3c2b5de..1ddf72e 100644 --- a/ordr2/templates/macros.jinja2 +++ b/ordr2/templates/macros.jinja2 @@ -16,16 +16,20 @@ {%- endmacro %} -{% macro filter_box(title, query_key, items) -%} +{% macro filter_box(title, query_key, items, extras=None) -%} + {% if not extras %} + {% set extras = dict() %} + {% endif %} + {% set extras_active = context|are_extras_active(extras) %}