Merge pull request #289 from mjtamlyn/slugify-real-function

Fixed bug in 212b982 -- Removed duplicate code in removetags
This commit is contained in:
Andrew Godwin 2012-08-18 09:41:06 -07:00
commit bf12c663d9
1 changed files with 2 additions and 7 deletions

View File

@ -468,13 +468,8 @@ def safeseq(value):
@stringfilter @stringfilter
def removetags(value, tags): def removetags(value, tags):
"""Removes a space separated list of [X]HTML tags from the output.""" """Removes a space separated list of [X]HTML tags from the output."""
tags = [re.escape(tag) for tag in tags.split()] from django.utils.html import remove_tags
tags_re = '(%s)' % '|'.join(tags) return remove_tags(value, tags)
starttag_re = re.compile(r'<%s(/?>|(\s+[^>]*>))' % tags_re, re.U)
endtag_re = re.compile('</%s>' % tags_re)
value = starttag_re.sub('', value)
value = endtag_re.sub('', value)
return value
@register.filter(is_safe=True) @register.filter(is_safe=True)
@stringfilter @stringfilter