diff options
Diffstat (limited to 'activities/templatetags')
-rw-r--r-- | activities/templatetags/activity_tags.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/activities/templatetags/activity_tags.py b/activities/templatetags/activity_tags.py index 571e2d6..fb822f6 100644 --- a/activities/templatetags/activity_tags.py +++ b/activities/templatetags/activity_tags.py @@ -3,6 +3,8 @@ import datetime from django import template from django.utils import timezone +from activities.models import Hashtag + register = template.Library() @@ -31,3 +33,14 @@ def timedeltashort(value: datetime.datetime): years = max(days // 365.25, 1) text = f"{years:0n}y" return text + + +@register.filter +def linkify_hashtags(value: str): + """ + Convert hashtags in content in to /tags/<hashtag>/ links. + """ + if not value: + return "" + + return Hashtag.linkify_hashtags(value) |