Created
August 23, 2018 14:49
-
-
Save DWboutin/a9563f8c99a31fa5acb8c479a4d94232 to your computer and use it in GitHub Desktop.
Django filter to transform HTML to a string with tags replaced by white spaces
This file contains 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 | |
from django.utils.html import format_html | |
from django.template.defaultfilters import stringfilter | |
register = template.Library() | |
@register.filter(name='convert_tags_to_space') | |
@stringfilter | |
def convert_tags_to_space(value): | |
import re | |
return re.sub('<.*?>', ' ', value).strip() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment