instance method
auto_link_urls
Ruby on Rails 2.2.3
Since v2.2.3 Last seen in v3.0.20 PrivateSignature
auto_link_urls(text, html_options = {})
Turns all urls into clickable links. If a block is given, each url is yielded and the result is used as the link text.
Parameters
-
textreq -
html_optionsopt = {}
Source
# File actionpack/lib/action_view/helpers/text_helper.rb, line 570
def auto_link_urls(text, html_options = {})
extra_options = tag_options(html_options.stringify_keys) || ""
text.gsub(AUTO_LINK_RE) do
all, a, b, c, d = $&, $1, $2, $3, $4
if a =~ /<a\s/i # don't replace URL's that are already linked
all
else
text = b + c
text = yield(text) if block_given?
%(#{a}<a href="#{b=="www."?"http://www.":b}#{c}"#{extra_options}>#{text}</a>#{d})
end
end
end
Defined in actionpack/lib/action_view/helpers/text_helper.rb line 570
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionView::Helpers::TextHelper