from re import sub from django import template from django.template.defaultfilters import stringfilter register = template.Library() @stringfilter @register.filter def force_br(value): """ For Flash, replace all
tags with
and strip newlines
"""
if not value:
return value
value = sub('
]*>', '', value)
value = sub('<\/p>', '
', value)
value = sub("\n", "", value)
return value