Last active
September 28, 2015 15:37
-
-
Save arvindhsukumar/1459405 to your computer and use it in GitHub Desktop.
Wikipedia auto-link generator for Rails
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
#app/helpers/application_helper.rb | |
def wikify(text) | |
text.gsub!(/(\<wp\>(.*?)\<\/wp\>)/) do |m| | |
n = m.gsub!(/(\<wp\>|<\/wp\>)/, '') | |
link_to(n, "http://en.wikipedia.org/wiki/#{n}") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment