Phone number parser and tel link creator.
gem install alexander_graham_bell
- Ruby 2.5.3 or higher
puts AlexanderGrahamBell.tel_link('1-800-555-1234')
# <a href=\"tel:18005551234\">1-800-555-1234</a>
puts AlexanderGrahamBell.tel_link('1-800-555-1234ext5')
#<a href=\"tel:18005551234;isub=5\">1-800-555-1234ext5</a>
puts AlexanderGrahamBell.tel_href('1-800-555-1234')
# tel:18005551234
# If you're using rails and you want to html escape everything, wrap it in your own module or class.
module MyTelLinkGenerator
def self.build(phone_number)
AlexanderGrahamBell.tel_link(phone_number).html_safe
end
end
MyTelLinkGenerator.build('+18052234567ext5')