diff options
author | Tom Willemse | 2013-05-09 20:07:49 +0200 |
---|---|---|
committer | Tom Willemse | 2013-05-09 20:07:49 +0200 |
commit | 15c5869b54e9a770b9abbeab1e990b713cdb1b3b (patch) | |
tree | 4aa805a44e8da93f4b0698520f16096d216d8ec3 /ryuslash/aggregator/templatetags/posts_extras.py | |
parent | 5f7df695ac6dd9ccc5444a8fc20fa8d97196953e (diff) | |
download | ryuslash.org-15c5869b54e9a770b9abbeab1e990b713cdb1b3b.tar.gz ryuslash.org-15c5869b54e9a770b9abbeab1e990b713cdb1b3b.zip |
Update for django 1.4
Diffstat (limited to 'ryuslash/aggregator/templatetags/posts_extras.py')
-rw-r--r-- | ryuslash/aggregator/templatetags/posts_extras.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/ryuslash/aggregator/templatetags/posts_extras.py b/ryuslash/aggregator/templatetags/posts_extras.py new file mode 100644 index 0000000..64718a2 --- /dev/null +++ b/ryuslash/aggregator/templatetags/posts_extras.py @@ -0,0 +1,20 @@ +import re + +from django import template +from django.template.defaultfilters import stringfilter + +register = template.Library() + +@stringfilter +def nameless(value): + return re.sub(r'(^|by[- ])(ryuslash|tom)[- ]?', '', value) + +@stringfilter +def truncate(value, length): + if len(value) > length: + value = value[:length-3] + '...' + + return value + +register.filter('nameless', nameless) +register.filter('truncate', truncate) |