Class: Refinery::Pages::CustomScrubber

Inherits:
Rails::Html::PermitScrubber
  • Object
show all
Defined in:
app/presenters/refinery/pages/section_presenter.rb

Instance Method Summary collapse

Constructor Details

#initialize(tags, attributes) ⇒ CustomScrubber

Returns a new instance of CustomScrubber.



88
89
90
91
92
# File 'app/presenters/refinery/pages/section_presenter.rb', line 88

def initialize(tags, attributes)
  @direction = :bottom_up
  @tags = tags
  @attributes = attributes
end

Instance Method Details

#allowed_node?(node) ⇒ Boolean

Returns:

  • (Boolean)


94
95
96
# File 'app/presenters/refinery/pages/section_presenter.rb', line 94

def allowed_node?(node)
  tags.include?(node.name)
end

#scrub_attribute?(name) ⇒ Boolean

Returns:

  • (Boolean)


102
103
104
# File 'app/presenters/refinery/pages/section_presenter.rb', line 102

def scrub_attribute?(name)
  attributes.exclude?(name) && name !~ /\Adata-[\w-]+\z/
end

#skip_node?(node) ⇒ Boolean

Returns:

  • (Boolean)


98
99
100
# File 'app/presenters/refinery/pages/section_presenter.rb', line 98

def skip_node?(node)
  node.text?
end