X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/1324f9b1e4d57c5ab50bc264507f7adc3207eb99..0959d38b27c03863ec376839dcc6d896d04e36ea:/philo/contrib/penfield/templatetags/penfield.py diff --git a/philo/contrib/penfield/templatetags/penfield.py b/philo/contrib/penfield/templatetags/penfield.py index 7b9d946..b263a2b 100644 --- a/philo/contrib/penfield/templatetags/penfield.py +++ b/philo/contrib/penfield/templatetags/penfield.py @@ -1,25 +1,17 @@ """ -Penfield supplies two template filters: - -.. templatefilter:: monthname - -monthname ---------- -Returns the name of a month with the supplied numeric value. - -.. templatefilter:: apmonthname - -apmonthname ------------ -Returns the Associated Press abbreviated month name for the supplied numeric value. +Penfield supplies two template filters to handle common use cases for blogs and newsletters. """ from django import template from django.utils.dates import MONTHS, MONTHS_AP + register = template.Library() + +@register.filter def monthname(value): + """Returns the name of a month with the supplied numeric value.""" try: value = int(value) except: @@ -30,9 +22,10 @@ def monthname(value): except KeyError: return value -register.filter('monthname', monthname) +@register.filter def apmonthname(value): + """Returns the Associated Press abbreviated month name for the supplied numeric value.""" try: value = int(value) except: @@ -41,6 +34,4 @@ def apmonthname(value): try: return MONTHS_AP[value] except KeyError: - return value - -register.filter('apmonthname', apmonthname) + return value \ No newline at end of file