Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update the documentation and add CHANGELOG entry

  • Loading branch information...
commit eedc513503785490a7caed23cd0a0aef3536759f 1 parent 4ce3b5d
@rafaelfranca rafaelfranca authored
View
2  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*
View
6 actionpack/lib/action_view/helpers/text_helper.rb
@@ -62,9 +62,9 @@ def safe_concat(string)
#
# Pass a <tt>:separator</tt> 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 <tt>raw()</tt>. 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..."
View
2  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 <tt>:omission</tt> string (defaults to "...")
- # for a total length not exceeding <tt>:length</tt>:
+ # for a total length not exceeding <tt>length</tt>:
#
# 'And they found that many people were sleeping better.'.truncate(25, :omission => '... (continued)')
# # => "And they f... (continued)"
Please sign in to comment.
Something went wrong with that request. Please try again.