New filters to strip leading zeroes, and change rendering of RFCs to be without space between 'RFC' and number

- Legacy-Id: 396
This commit is contained in:
Henrik Levkowetz 2007-06-15 11:46:36 +00:00
parent 8a3936dfa5
commit de55978562

View file

@ -139,3 +139,19 @@ def rfcspace(string):
else: else:
return string return string
@register.filter(name='rfcnospace')
def rfcspace(string):
"""
If the string is an RFC designation, and does have
a space between 'RFC' and the rfc-number, remove it.
"""
string = str(string)
if string[:3].lower() == "rfc" and string[3] == " ":
return string[:3] + string[4:]
else:
return string
@register.filter(name='lstrip')
def lstripw(string, chars):
"""Strip matching leading characters from words in string"""
return " ".join([word.lstrip(chars) for word in string.split()])