Add twitter_handle tag
This commit is contained in:
parent
fe43a26ca5
commit
45b65340e1
2 changed files with 7 additions and 2 deletions
|
@ -33,7 +33,7 @@
|
||||||
<p>
|
<p>
|
||||||
<strong>{{ speaker }}</strong><br />
|
<strong>{{ speaker }}</strong><br />
|
||||||
{% if speaker.twitter_username %}
|
{% if speaker.twitter_username %}
|
||||||
<a href="https://twitter.com/{{ speaker.twitter_username }}">{{ speaker.twitter_username }}</a><br />
|
<a href="https://twitter.com/{{ speaker.twitter_username }}">{{ speaker.twitter_username|twitter_handle }}</a><br />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if speaker.homepage %}
|
{% if speaker.homepage %}
|
||||||
<a href="{{ speaker.homepage }}">{{ speaker.homepage }}</a>
|
<a href="{{ speaker.homepage }}">{{ speaker.homepage }}</a>
|
||||||
|
|
|
@ -36,4 +36,9 @@ def listlookup(lookup, target):
|
||||||
@register.filter
|
@register.filter
|
||||||
def clean_text(txt):
|
def clean_text(txt):
|
||||||
# Remove double/triple/+ spaces from `txt` and replace with single space
|
# Remove double/triple/+ spaces from `txt` and replace with single space
|
||||||
return re.sub(r' {2,}' , ' ', txt)
|
return re.sub(r' {2,}' , ' ', txt)
|
||||||
|
|
||||||
|
@register.filter
|
||||||
|
def twitter_handle(txt):
|
||||||
|
# Add @ to twitter handle if not present
|
||||||
|
return txt if txt.startswith('@') else '@{}'.format(txt)
|
Loading…
Reference in a new issue