method
strip_tags
Ruby on Rails latest stable (v7.1.3.2)
-
1 note -
Class: ActionView::Helpers::SanitizeHelper
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3 (0)
- 2.1.0 (0)
- 2.2.1 (-1)
- 2.3.8 (0)
- 3.0.0 (0)
- 3.0.9 (-8)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (-5)
- 4.1.8 (0)
- 4.2.1 (-36)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (38)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- 7.2.3 (0)
- 8.0.0 (0)
- 8.1.1 (0)
- What's this?
strip_tags(html)
public
Strips all HTML tags from html, including comments and special characters.
strip_tags("Strip <i>these</i> tags!") # => Strip these tags! strip_tags("<b>Bold</b> no more! <a href='more.html'>See more here</a>...") # => Bold no more! See more here... strip_tags("<div id='top-bar'>Welcome to my website!</div>") # => Welcome to my website! strip_tags("> A quote from Smith & Wesson") # => > A quote from Smith & Wesson
Register or
log in
to add new notes.
k776 -
April 21, 2009
5 thanks
strip_tags method not functioning in controllers, models, or libs
It comes up with an error about white_list_sanitizer undefined in the class you’re using it in. To get around this, use:
ActionController::Base.helpers.strip_tags('string')
To shorten this, add something like this in an initializer:
class String def strip_tags ActionController::Base.helpers.strip_tags(self) end end
then call it with:
'string'.strip_tags

