class Loofah::Scrubbers::NoFollow

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>"

Public Class Methods

new() click to toggle source
# File lib/loofah/scrubbers.rb, line 189
def initialize
  @direction = :top_down
end

Public Instance Methods

scrub(node) click to toggle source
# File lib/loofah/scrubbers.rb, line 193
def scrub(node)
  return CONTINUE unless (node.type == Nokogiri::XML::Node::ELEMENT_NODE) && (node.name == 'a')
  node.set_attribute('rel', 'nofollow')
  return STOP
end