Skip to content

Instantly share code, notes, and snippets.

@itsterry
Created May 2, 2013 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itsterry/5501248 to your computer and use it in GitHub Desktop.
Save itsterry/5501248 to your computer and use it in GitHub Desktop.
#turn an email address into a javascript-built email link, to frustrate email harvest bots
def protected_email_link(e=nil)
if e.present?
name,domain=e.split('@')
content_tag(:script,type:"text/javascript") do
raw("emailE=('#{name}'+'@'+'#{domain}');"+
"document.write('<a href=\"mailto:' + emailE + '\">'+ emailE + '</a>');")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment