diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-06-21 07:16:11 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-06-21 07:16:11 +0000 |
commit | c608ebeade50d3e87e750486e4949e8c3bdf1549 (patch) | |
tree | 404482786b05a35af2ab4ab5ee7eaac4ec959a1d /actionpack/lib | |
parent | e59bfc85196cc4921f87b4b145048b7fa1fbbabb (diff) | |
download | rails-c608ebeade50d3e87e750486e4949e8c3bdf1549.tar.gz rails-c608ebeade50d3e87e750486e4949e8c3bdf1549.tar.bz2 rails-c608ebeade50d3e87e750486e4949e8c3bdf1549.zip |
Added TextHelper#word_wrap(text, line_length = 80) #1449 [tuxie@dekadance.se]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1465 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/text_helper.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index a65a979343..5e1a2e66ce 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -65,6 +65,11 @@ module ActionView end end + # Word wrap long lines to line_width. + def word_wrap(text, line_width = 80) + text.gsub(/\n/, "\n\n").gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip + end + begin require "redcloth" |