Created
March 31, 2010 23:32
-
-
Save brandonweiss/351097 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use Hpricot to add rel="nofollow" to anchor links before output | |
require 'hpricot' | |
def add_nofollow(body) | |
body = Hpricot(body) | |
a_elements = body.search('a') | |
unless a_elements.blank? | |
a_elements.each do |a| | |
a.attributes['rel'] = 'nofollow' | |
end | |
end | |
body.to_html | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment