Created
October 10, 2015 02:21
-
-
Save jangeador/c38065fb0268a315ee2b to your computer and use it in GitHub Desktop.
template tag to render boolean as a nice icon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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