instance method
auto_link_email_addresses
Ruby on Rails 2.2.3
Since v2.2.3 Last seen in v3.0.20 PrivateSignature
auto_link_email_addresses(text)
Turns all email addresses into clickable links. If a block is given, each email is yielded and the result is used as the link text.
Parameters
-
textreq
Source
# File actionpack/lib/action_view/helpers/text_helper.rb, line 586
def auto_link_email_addresses(text)
body = text.dup
text.gsub(/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/) do
text = $1
if body.match(/<a\b[^>]*>(.*)(#{Regexp.escape(text)})(.*)<\/a>/)
text
else
display_text = (block_given?) ? yield(text) : text
%{<a href="mailto:#{text}">#{display_text}</a>}
end
end
end
Defined in actionpack/lib/action_view/helpers/text_helper.rb line 586
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionView::Helpers::TextHelper