1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | from django import template
register = template.Library()
def mask_email(email):
"""Mask an email address."""
name, domain = email.split('@')
if len(name) > 5:
# show the first 3 characters
masked_name = name[:3]
else:
# just use the 1st character
masked_name = name[0]
return "%s...@%s" % (masked_name, domain)
register.filter('mask_email', mask_email)
|
More like this
- email_links by sansmojo 5 years, 11 months ago
- Form splitting/Fieldset templatetag by peritus 4 years, 8 months ago
- Unique field inline formset by dcwatson 8 months, 1 week ago
- IfValueTag by adurdin 6 years, 2 months ago
- Generate QR Code image for a string by johnnoone 4 years ago
Comments
Best. Snippet. EVAR!
#
very nice. i added the filter to djazz
#
I used this snippet in a new snippet I just posted. Hope you don't mind, jkocherhans :)
It's at http://www.djangosnippets.org/snippets/265/
#