Ticket #1684: defaultfilters.3.diff
File defaultfilters.3.diff, 927 bytes (added by , 19 years ago) |
---|
-
defaultfilters.py
63 63 """ 64 64 return list(str(value)) 65 65 66 def numerize(value): 67 """ 68 For numbers 1-9, returns the number spelled out. Otherwise, returns 69 the number. 70 """ 71 if type(value) is not int or not 0 < value < 10: 72 return value 73 as_words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine'] 74 return as_words[value-1] 75 66 76 def slugify(value): 67 77 "Converts to lowercase, removes non-alpha chars and converts spaces to hyphens" 68 78 value = re.sub('[^\w\s-]', '', value).strip().lower() … … 463 473 register.filter(ljust) 464 474 register.filter(lower) 465 475 register.filter(make_list) 476 register.filter(numerize) 466 477 register.filter(phone2numeric) 467 478 register.filter(pluralize) 468 479 register.filter(pprint)