Django: Stop filter from always escaping HTML

The majority of the time, Django's automatic escaping of filter output is very handy. But sometimes you actually want the output to be unescaped HTML, so for that you can use the "is_safe" property.

@register.filter
def add_xx(value):
return '<%s>Blah blah blah</%s>' % (value, value)
add_xx.is_safe = True

[ Source ]

 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog