From ae6b1088108cad10f10852a15b186027f8568e99 Mon Sep 17 00:00:00 2001 From: Davide Setti Date: Wed, 4 Jan 2012 14:53:36 +0100 Subject: [PATCH 1/2] add is_active stringfilter --- gargoyle/templatetags/gargoyle_tags.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gargoyle/templatetags/gargoyle_tags.py b/gargoyle/templatetags/gargoyle_tags.py index 44dcc3b6..0ccb488b 100644 --- a/gargoyle/templatetags/gargoyle_tags.py +++ b/gargoyle/templatetags/gargoyle_tags.py @@ -50,3 +50,15 @@ def render(self, context): return self.nodelist_false.render(context) return self.nodelist_true.render(context) + + +@register.filter +def is_active(request, switch): + """ + filter to use gargoyle switches in normal ifs: + + {% if request|is_active:"switchname" and not user.is_anonymous %} + html + {% endif %} + """ + return gargoyle.is_active(switch) From 66f875d4afde90c50a6b248b75d59eb7b7a9268d Mon Sep 17 00:00:00 2001 From: Davide Setti Date: Wed, 4 Jan 2012 15:01:04 +0100 Subject: [PATCH 2/2] ehm... gargoyle.is_active(switch) -> gargoyle.is_active(switch, request) in is_active stringfilter --- gargoyle/templatetags/gargoyle_tags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gargoyle/templatetags/gargoyle_tags.py b/gargoyle/templatetags/gargoyle_tags.py index 0ccb488b..bf58e6ca 100644 --- a/gargoyle/templatetags/gargoyle_tags.py +++ b/gargoyle/templatetags/gargoyle_tags.py @@ -61,4 +61,4 @@ def is_active(request, switch): html {% endif %} """ - return gargoyle.is_active(switch) + return gargoyle.is_active(switch, request)