instance method auto_link_urls

Ruby on Rails 2.2.3

Since v2.2.3 Last seen in v3.0.20 Private

Available in: v2.2.3 v2.3.18 v3.0.20

Signature

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

text req
html_options opt = {}
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

Type at least 2 characters to search.

↑↓ navigate · open · esc close