add Slugify filter
This commit is contained in:
parent
13b9a7471f
commit
130cec8c5a
1 changed files with 8 additions and 0 deletions
|
|
@ -422,6 +422,14 @@ class CleanDecimal(CleanText):
|
|||
return self.default_or_raise(e)
|
||||
|
||||
|
||||
class Slugify(Filter):
|
||||
@debug()
|
||||
def filter(self, label):
|
||||
label = re.sub(r'[^A-Za-z0-9]', ' ', label.lower()).strip()
|
||||
label = re.sub(r'\s+', '-', label)
|
||||
return label
|
||||
|
||||
|
||||
class Type(Filter):
|
||||
"""
|
||||
Get a cleaned value of any type from an element text.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue