instance method strip_links

Ruby on Rails 8.1.2

Since v2.2.3

Available in: v2.2.3 v2.3.18 v3.0.20 v3.1.12 v3.2.22.5 v4.0.13 v4.1.16 v4.2.9 v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

strip_links(html)

Strips all link tags from html leaving just the link text.

strip_links('<a href="http://www.rubyonrails.org">Ruby on Rails</a>')
# => Ruby on Rails

strip_links('Please e-mail me at <a href="mailto:me@email.com">me@email.com</a>.')
# => Please e-mail me at me@email.com.

strip_links('Blog: <a href="http://www.myblog.com/" class="nav" target=\"_blank\">Visit</a>.')
# => Blog: Visit.

strip_links('<<a href="https://example.org">malformed & link</a>')
# => &lt;malformed &amp; link

Parameters

html req
Source
# File actionview/lib/action_view/helpers/sanitize_helper.rb, line 156
      def strip_links(html)
        self.class.link_sanitizer.sanitize(html)
      end

Defined in actionview/lib/action_view/helpers/sanitize_helper.rb line 156 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionView::Helpers::SanitizeHelper

Type at least 2 characters to search.

↑↓ navigate · open · esc close