Class: Loofah::Scrubbers::NoOpener
- Inherits:
-
Loofah::Scrubber
- Object
- Loofah::Scrubber
- Loofah::Scrubbers::NoOpener
- Defined in:
- lib/loofah/scrubbers.rb
Overview
scrub!(:noopener)
+:noopener+ adds a rel="noopener" attribute to all links
link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
Loofah.html5_fragment(link_farmers_markup).scrub!(:noopener)
=> "ohai! <a href='http://www.myswarmysite.com/' rel="noopener">I like your blog post</a>"
Constant Summary
Constants inherited from Loofah::Scrubber
Loofah::Scrubber::CONTINUE, Loofah::Scrubber::STOP
Instance Attribute Summary
Attributes inherited from Loofah::Scrubber
Instance Method Summary collapse
-
#initialize ⇒ NoOpener
constructor
rubocop:disable Lint/MissingSuper.
- #scrub(node) ⇒ Object
Methods inherited from Loofah::Scrubber
Constructor Details
permalink #initialize ⇒ NoOpener
rubocop:disable Lint/MissingSuper
272 273 274 |
# File 'lib/loofah/scrubbers.rb', line 272 def initialize # rubocop:disable Lint/MissingSuper @direction = :top_down end |
Instance Method Details
permalink #scrub(node) ⇒ Object
[View source]
276 277 278 279 280 281 |
# File 'lib/loofah/scrubbers.rb', line 276 def scrub(node) return CONTINUE unless (node.type == Nokogiri::XML::Node::ELEMENT_NODE) && (node.name == "a") append_attribute(node, "rel", "noopener") STOP end |