Skip to content

Commit

Permalink
Adding is_on filter.
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanborror committed Mar 19, 2011
1 parent 3d2a05a commit 84f5ebd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions basic/tools/templatetags/comparison.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.template import Library
from django.template.defaultfilters import lower
from django.utils.safestring import mark_safe

register = Library()

Expand Down Expand Up @@ -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.