Class: Loofah::Scrubbers::TargetBlank
- Inherits:
-
Loofah::Scrubber
- Object
- Loofah::Scrubber
- Loofah::Scrubbers::TargetBlank
- Defined in:
- lib/loofah/scrubbers.rb
Overview
scrub!(:targetblank)
+:targetblank+ adds a target="_blank" attribute to all links.
If there is a target already set, replaces it with target="_blank".
link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
Loofah.html5_fragment(link_farmers_markup).scrub!(:targetblank)
=> "ohai! <a href='http://www.myswarmysite.com/' target="_blank">I like your blog post</a>"
On modern browsers, setting target="_blank" on anchor elements implicitly provides the same
behavior as setting rel="noopener".
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 ⇒ TargetBlank
constructor
rubocop:disable Lint/MissingSuper.
- #scrub(node) ⇒ Object
Methods inherited from Loofah::Scrubber
Constructor Details
#initialize ⇒ TargetBlank
rubocop:disable Lint/MissingSuper
247 248 249 |
# File 'lib/loofah/scrubbers.rb', line 247 def initialize # rubocop:disable Lint/MissingSuper @direction = :top_down end |