Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding is_on filter.

  • Loading branch information...
commit 84f5ebdcc0d4c54b973d89634ae2135822c4d26f 1 parent 3d2a05a
@nathanborror authored
Showing with 11 additions and 0 deletions.
  1. +11 −0 basic/tools/templatetags/comparison.py
View
11 basic/tools/templatetags/comparison.py
@@ -1,5 +1,6 @@
from django.template import Library
from django.template.defaultfilters import lower
+from django.utils.safestring import mark_safe
register = Library()
@@ -43,3 +44,13 @@ def is_string(obj):
@register.filter
def is_number(obj):
return isinstance(obj, int)
+
+
+@register.filter
+def is_on(obj1, obj2):
+ """
+ Shortcut to render an 'on' class.
+ """
+ if obj1 == obj2:
+ return mark_safe(' class="on"')
+ return ''

0 comments on commit 84f5ebd

Please sign in to comment.
Something went wrong with that request. Please try again.