Class: Loofah::Scrubbers::NoFollow
- Inherits:
-
Loofah::Scrubber
- Object
- Loofah::Scrubber
- Loofah::Scrubbers::NoFollow
- Defined in:
- lib/loofah/scrubbers.rb
Overview
scrub!(:nofollow)
+:nofollow+ adds a rel="nofollow" attribute to all links
link_farmers_markup = "ohai! <a href='http://www.myswarmysite.com/'>I like your blog post</a>"
Loofah.fragment(link_farmers_markup).scrub!(:nofollow)
=> "ohai! <a href='http://www.myswarmysite.com/' rel="nofollow">I like your blog post</a>"
Constant Summary
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)
-
- (NoFollow) initialize
constructor
A new instance of NoFollow.
- - (Object) scrub(node)
Methods inherited from Loofah::Scrubber
Constructor Details
- (NoFollow) initialize
A new instance of NoFollow
174 175 176 |
# File 'lib/loofah/scrubbers.rb', line 174 def initialize @direction = :top_down end |
Instance Method Details
- (Object) scrub(node)
178 179 180 181 182 |
# File 'lib/loofah/scrubbers.rb', line 178 def scrub(node) return CONTINUE unless (node.type == Nokogiri::XML::Node::ELEMENT_NODE) && (node.name == 'a') node.set_attribute('rel', 'nofollow') return STOP end |