Skip to content
This repository has been archived by the owner on Jun 20, 2018. It is now read-only.

add is_active stringfilter #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions gargoyle/templatetags/gargoyle_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
<my>html</my>
{% endif %}
"""
return gargoyle.is_active(switch, request)