aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/text_helper.rb
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2010-02-14 19:28:05 +0000
committerPratik Naik <pratiknaik@gmail.com>2010-02-14 19:28:05 +0000
commit6f3c5f67870a625b8be4de6e34e8d0d2f5d2b5e3 (patch)
tree3da8d75101aabe3c1d90d0582505ec1480c9d885 /actionpack/lib/action_view/helpers/text_helper.rb
parent77bf78b3b78a41d4f2f6e733f5c9c00608c0adba (diff)
parenta1b60696e2b13cbe94d748444cc0da37b190fbb8 (diff)
downloadrails-6f3c5f67870a625b8be4de6e34e8d0d2f5d2b5e3.tar.gz
rails-6f3c5f67870a625b8be4de6e34e8d0d2f5d2b5e3.tar.bz2
rails-6f3c5f67870a625b8be4de6e34e8d0d2f5d2b5e3.zip
Merge remote branch 'mainstream/master'
Conflicts: railties/README railties/guides/source/active_support_core_extensions.textile railties/guides/source/getting_started.textile railties/lib/generators/rails/app/templates/README
Diffstat (limited to 'actionpack/lib/action_view/helpers/text_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/text_helper.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb
index 2e02f6637a..644f34dbbe 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionpack/lib/action_view/helpers/text_helper.rb
@@ -187,7 +187,7 @@ module ActionView
# pluralize(0, 'person')
# # => 0 people
def pluralize(count, singular, plural = nil)
- "#{count || 0} " + ((count == 1 || count == '1') ? singular : (plural || singular.pluralize))
+ "#{count || 0} " + ((count == 1 || count =~ /^1(\.0+)?$/) ? singular : (plural || singular.pluralize))
end
# Wraps the +text+ into lines no longer than +line_width+ width. This method
@@ -327,12 +327,12 @@ module ActionView
# # => "<p class='description'>Look ma! A class!</p>"
def simple_format(text, html_options={})
start_tag = tag('p', html_options, true)
- text = text.to_s.dup
+ text = h(text)
text.gsub!(/\r\n?/, "\n") # \r\n and \r -> \n
text.gsub!(/\n\n+/, "</p>\n\n#{start_tag}") # 2+ newline -> paragraph
text.gsub!(/([^\n]\n)(?=[^\n])/, '\1<br />') # 1 newline -> br
text.insert 0, start_tag
- text << "</p>"
+ text.safe_concat("</p>")
end
# Turns all URLs and e-mail addresses into clickable links. The <tt>:link</tt> option