Skip to content

Instantly share code, notes, and snippets.

@lwe
Created July 27, 2011 14:25
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 lwe/1109456 to your computer and use it in GitHub Desktop.
Save lwe/1109456 to your computer and use it in GitHub Desktop.
module TelHelper
# Erstellt einen <a href="tel:..."> link.
def tel_to(telephone_number, name = nil, html_options = {})
href = html_escape telephone_number.to_s.strip.sub(/\A\+/, '00').gsub(/(\(.+\))/, '').gsub(/[^\d]/, '')
content_tag "a", name || telephone_number, html_options.stringify_keys.merge("href" => "tel:#{href}".html_safe)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment