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.



187
188
189
# File 'lib/rails/html/scrubbers.rb', line 187

def initialize
  @direction = :bottom_up
end

Instance Method Details

#scrub(node) ⇒ Object



191
192
193
194
195
196
197
198
# File 'lib/rails/html/scrubbers.rb', line 191

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