Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'base64'
- require 'uri'
- require 'liquid'
- module ObfuscateMailAddress
- def mailObfuscate(email_address, link_text)
- base64Mail = Base64.strict_encode64(URI::encode(email_address))
- ouput = <<~HTML
- <a href="#" data-contact="#{base64Mail}" target="_blank"
- onfocus="this.href = 'mailto:' + atob(this.dataset.contact)" >
- <script type="text/javascript">
- document.write(atob("#{base64Mail}"));
- </script>
- #{link_text}
- </a>
- HTML
- end
- end
- Liquid::Template.register_filter(ObfuscateMailAddress)
- puts template.render
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement