Encode emails as URIs

 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

  1. Class-Based AJAX fallback view by fahhem 2 years, 3 months ago
  2. Resolve URLs to view name and args/kwargs by fahhem 2 years, 6 months ago
  3. Template tag to create mailto links with options by celopes 3 years, 11 months ago
  4. encode_mailto by santuri 6 years ago
  5. hide_email by rukeba 5 years ago

Comments

(Forgotten your password?)