From eedc513503785490a7caed23cd0a0aef3536759f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Sat, 26 May 2012 13:56:42 -0300 Subject: [PATCH] Update the documentation and add CHANGELOG entry --- actionpack/CHANGELOG.md | 2 ++ actionpack/lib/action_view/helpers/text_helper.rb | 6 +++--- activesupport/lib/active_support/core_ext/string/filters.rb | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index 920858d8c07b..db5e40b07c9c 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,5 +1,7 @@ ## Rails 4.0.0 (unreleased) ## +* `truncate` now accepts a block to show extra content when the text is truncated. *Li Ellis Gallardo* + * Add `week_field`, `week_field_tag`, `month_field`, `month_field_tag`, `datetime_local_field`, `datetime_local_field_tag`, `datetime_field` and `datetime_field_tag` helpers. *Carlos Galdino* diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index 73c3c61a41f6..72f9dd2cefea 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -62,9 +62,9 @@ def safe_concat(string) # # Pass a :separator to truncate +text+ at a natural break. # - # The result is not marked as HTML-safe, so will be subject to the default escaping when - # used in views, unless wrapped by raw(). Care should be taken if +text+ contains HTML tags - # or entities, because truncation may produce invalid HTML (such as unbalanced or incomplete tags). + # Pass a block if you want to show extra content when the text is truncated. + # + # The result is marked as HTML-safe, but the it is escaped first. # # truncate("Once upon a time in a world far far away") # # => "Once upon a time in a world..." diff --git a/activesupport/lib/active_support/core_ext/string/filters.rb b/activesupport/lib/active_support/core_ext/string/filters.rb index 2478f42290d9..70f2dcb5620b 100644 --- a/activesupport/lib/active_support/core_ext/string/filters.rb +++ b/activesupport/lib/active_support/core_ext/string/filters.rb @@ -33,7 +33,7 @@ def squish! # # => "Once upon a time in a..." # # The last characters will be replaced with the :omission string (defaults to "...") - # for a total length not exceeding :length: + # for a total length not exceeding length: # # 'And they found that many people were sleeping better.'.truncate(25, :omission => '... (continued)') # # => "And they f... (continued)"