This method is deprecated or moved on the latest stable version.
The last existing version (v1.2.6) is shown here.
strip_tags(html)
public
Strips all HTML tags from the html,
including comments. This uses the html-scanner tokenizer and so its HTML parsing ability is limited by that of
html-scanner.
# File actionpack/lib/action_view/helpers/text_helper.rb, line 256
def strip_tags(html)
return html if html.blank?
if html.index("<")
text = ""
tokenizer = HTML::Tokenizer.new(html)
while token = tokenizer.next
node = HTML::Node.parse(nil, 0, 0, token, false)
# result is only the content of any Text nodes
text << node.to_s if node.class == HTML::Text
end
# strip any comments, and if they have a newline at the end (ie. line with
# only a comment) strip that too
text.gsub(/<!--(.*?)-->[\n]?/m, "")
else
html # already plain text
end
end