Skip to content

Instantly share code, notes, and snippets.

@dancek
Created November 7, 2013 12:47
Show Gist options
  • Save dancek/7354053 to your computer and use it in GitHub Desktop.
Save dancek/7354053 to your computer and use it in GitHub Desktop.
Given an angular module _r, this is a directive for obfuscating an email address. Would be easy to parameterize and release as a module.
_r.directive 'obfuscateEmail', ->
scope:
email: '='
link: (scope, element) ->
rnd = Math.random().toString(36).substr(2,3)
re = /@/
obfuscated = scope.email?.replace re, "<span class=\"obfuscate\">#{rnd}</span>$&"
element.html obfuscated
@dancek
Copy link
Author

dancek commented Nov 7, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment