Skip to content

Instantly share code, notes, and snippets.

@jangeador
Created October 10, 2015 02:21
Show Gist options
  • Save jangeador/c38065fb0268a315ee2b to your computer and use it in GitHub Desktop.
Save jangeador/c38065fb0268a315ee2b to your computer and use it in GitHub Desktop.
template tag to render boolean as a nice icon
from django import template
register = template.Library()
@register.filter()
def bool_me(value):
'''
Renders Boolean as a nice FontAwesome Icon.
:param value:
:return:
'''
if value is None:
return '<i class="fa fa-question fa-lg text-muted"></i>'
elif value:
return '<i class="fa fa-check-circle fa-lg text-success"></i>'
else:
return '<i class="fa fa-minus-circle fa-lg text-danger"></i>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment