- Author:
- fahhem
- Posted:
- August 18, 2010
- Language:
- Python
- Version:
- 1.2
- Tags:
- templatetag email spam encode
- Score:
- 1 (after 1 ratings)
Put this snippet in a file in a templatetags/ directory and load it in your templates. Then use it to encode your emails:
{{"[email protected]"|html_encode_email}}
Or if you want some control over the anchor tag:
<a href="mailto:{{"[email protected]"|html_encode}}&subject=Feedback">Send Feedback</a>
From fahhem.com and Recrec Labs
1 2 3 4 5 6 7 8 9 10 11 12 13 | from django import template
register = template.Library()
@register.filter
def html_encode(text):
return ''.join(map(lambda c:'%%%x'%ord(c),text))
html_encode.is_safe=True
@register.filter
def html_encode_email(email):
return '<a href="mailto:%s">%s</a>' % (html_encode(email),email)
html_encode_email.is_safe=True
|
More like this
- Automatically setup raw_id_fields ForeignKey & OneToOneField by agusmakmun 8 months ago
- Crispy Form by sourabhsinha396 8 months, 4 weeks ago
- ReadOnlySelect by mkoistinen 9 months, 1 week ago
- Verify events sent to your webhook endpoints by santos22 10 months, 1 week ago
- Django Language Middleware by agusmakmun 10 months, 2 weeks ago
Comments
Please login first before commenting.