From 0b3f99a8bb7081c38e9407413e9aac9bd125241e Mon Sep 17 00:00:00 2001 From: Thierry Schellenbach Date: Fri, 15 Jul 2011 12:22:42 +0200 Subject: [PATCH 1/2] template tag added to support jinja --- gargoyle/templatetags/jinja_tags.py | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 gargoyle/templatetags/jinja_tags.py diff --git a/gargoyle/templatetags/jinja_tags.py b/gargoyle/templatetags/jinja_tags.py new file mode 100644 index 00000000..5878ba47 --- /dev/null +++ b/gargoyle/templatetags/jinja_tags.py @@ -0,0 +1,33 @@ +from coffin.template import Library +from django.conf import settings +from django.template.defaultfilters import slugify +from gargoyle import gargoyle +import logging + +logger = logging.getLogger(__name__) +register = Library() + +@register.object +def switch_is_active(switch_slug, *instances): + ''' + Jinja implementation for the ifswitch + Usage: + {% if switch_is_active('myspecialfeature') %} + {% endif %} + + providing a request object (for ip based switches) + {% if switch_is_active('myspecialfeature', request) %} + {% endif %} + + providing the user for user based switches + {% if switch_is_active('myspecialfeature', user) %} + {% endif %} + ''' + assert slugify(switch_slug) == switch_slug, 'switch slug should be a valid slug' + + + is_active = gargoyle.is_active(switch_slug, *instances) + logger.info('Switch %s is active is %s, based on these instances %s', switch_slug, is_active, map(type,instances)) + + return is_active + From f33af9602765dcf60aaf0f5b3bbef94bb8245ebd Mon Sep 17 00:00:00 2001 From: Thierry Schellenbach Date: Fri, 15 Jul 2011 12:51:07 +0200 Subject: [PATCH 2/2] upped version number for requirements file --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1c3c62e9..633f2525 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ setup( name='gargoyle', - version='0.2.3', + version='0.2.4', author='DISQUS', author_email='opensource@disqus.com', url='http://github.com/disqus/gargoyle',