auto_link(text, link = :all, href_options = {}, &block) public

Turns all urls and email addresses into clickable links. The link parameter will limit what should be linked. You can add html attributes to the links using href_options. Options for link are :all (default), :email_addresses, and :urls.

  auto_link("Go to http://www.rubyonrails.org and say hello to david@loudthinking.com") =>
    Go to <a href="http://www.rubyonrails.org">http://www.rubyonrails.org</a> and
    say hello to <a href="mailto:david@loudthinking.com">david@loudthinking.com</a>

If a block is given, each url and email address is yielded and the result is used as the link text.

  auto_link(post.body, :all, :target => '_blank') do |text|
    truncate(text, 15)
  end
Show source
Register or log in to add new notes.