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. Hide Emails by epicserve 5 years, 1 month ago
  2. encode_mailto by santuri 6 years, 11 months ago
  3. hide_email by rukeba 5 years, 11 months ago
  4. filter for extracting a number of paragraphs from any HTML code by rafadev 2 years, 10 months ago
  5. better paginator template tag by amitu 5 years, 6 months ago

Comments

(Forgotten your password?)