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.


184
185
186
# File 'lib/rails/html/scrubbers.rb', line 184

def initialize
  @direction = :bottom_up
end

Instance Method Details

#scrub(node) ⇒ Object


188
189
190
191
192
193
194
195
# File 'lib/rails/html/scrubbers.rb', line 188

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