Class: Rails::HTML::TextOnlyScrubber

Inherits:
Loofah::Scrubber
  • Object
show all
Defined in:
lib/rails/html/scrubbers.rb

Overview

Rails::HTML::TextOnlyScrubber

Rails::HTML::TextOnlyScrubber allows you to permit text nodes.

Unallowed elements will be stripped, i.e. element is removed but its subtree kept.

Instance Method Summary collapse

Constructor Details

#initializeTextOnlyScrubber

Returns a new instance of TextOnlyScrubber.



211
212
213
# File 'lib/rails/html/scrubbers.rb', line 211

def initialize
  @direction = :bottom_up
end

Instance Method Details

#scrub(node) ⇒ Object



215
216
217
218
219
220
221
222
# File 'lib/rails/html/scrubbers.rb', line 215

def scrub(node)
  if node.text?
    CONTINUE
  else
    node.before node.children
    node.remove
  end
end