aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2005-11-18 01:25:39 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2005-11-18 01:25:39 +0000
commitfb3fc46cddfe5d1a5f8a4cfb10aac94a11b4c77d (patch)
treee9e3349451ebd3b9ae73fc47a933ee5694515140 /actionpack/lib/action_view/helpers
parent173544f56cb3cbdd5866a864ce3e287c8c86ce1e (diff)
downloadrails-fb3fc46cddfe5d1a5f8a4cfb10aac94a11b4c77d.tar.gz
rails-fb3fc46cddfe5d1a5f8a4cfb10aac94a11b4c77d.tar.bz2
rails-fb3fc46cddfe5d1a5f8a4cfb10aac94a11b4c77d.zip
Correct length for the truncate text helper. Closes #2913.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3080 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-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 b31668203e..2c38ffb345 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionpack/lib/action_view/helpers/text_helper.rb
@@ -20,12 +20,12 @@ module ActionView
# if the +text+ is longer than +length+.
def truncate(text, length = 30, truncate_string = "...")
if text.nil? then return end
-
+ l = length - truncate_string.length
if $KCODE == "NONE"
- text.length > length ? text[0..(length - 3)] + truncate_string : text
+ text.length > length ? text[0...l] + truncate_string : text
else
chars = text.split(//)
- chars.length > length ? chars[0..(length-3)].join + truncate_string : text
+ chars.length > length ? chars[0...l].join + truncate_string : text
end
end