Skip to content

@mudge /application_helper.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Widon't helpers for Rails (both the original and 2.1 versions).
module ApplicationHelper
# Shaun Inman's original Widon't
# http://shauninman.com/archive/2006/08/22/widont_wordpress_plugin
#
# @param [String] text the text to apply Widon't to
# @return [String] the text with Widon't applied
def widont(text)
text.strip!
text[text.rindex(' '), 1] = ' ' if text.rindex(' ')
text
end
# Widon't 2.1 (the update based on Matthew Mullenweg's regular expression)
# http://www.shauninman.com/archive/2007/01/03/widont_2_1_wordpress_plugin
#
# @param [String] text the text to apply Widon't to
# @return [String] a copy of the text with Widon't applied
def widont(text)
text.gsub(/([^\s])\s+([^\s]+)\s*$/, '\1 \2')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.