1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # Template tags file
from django.utils.safestring import mark_safe
import re
@register.filter(name='at_reply')
def twitter_at_reply(tweet):
pattern = re.compile(r"(\A|\W)@(?P<user>\w+)(\Z|\W)")
repl = (r'\1@<a href="http://twitter.com/\g<user>"'
r' title="\g<user> on Twitter">\g<user></a>\3')
return mark_safe(pattern.sub(repl, tweet))
# Template usage
{% load TAG_LIBRARY_NAME %}
{{ status.status|at_reply }}
|
More like this
- @reply links and hash tags in Twitter messages by dougal 4 years, 2 months ago
- Twitterfy by dougal 3 years, 8 months ago
- Remove self links middleware by svetlyak 5 years, 1 month ago
- Twitter template tags and filters by moxypark 2 years, 9 months ago
- twitterize filter by thomasw 4 years, 1 month ago
Comments
Thanks for the props! It looks awesome in action.
#