diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index 700c0b9e3b5ad7eb1b8f9bf3fcf6c39b86f3073c..cefabd72aad13b259492bccd4547ed32aafe4491 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -39,6 +39,7 @@ def safe_concat(string) # for a total length not exceeding :length. # # Pass a :separator to truncate +text+ at a natural break. + # Pass a :safe (which defaults to false) to escape or not the input. If :safe => true the input is not escaped. # # ==== Examples # @@ -54,6 +55,15 @@ def safe_concat(string) # truncate("And they found that many people were sleeping better.", :length => 25, :omission => '... (continued)') # # => "And they f... (continued)" # + # truncate("

Once upon a time in a world far far away

") + # # => "<p>Once upon a time i..." + # + # truncate("

Once upon a time in a world far far away

", :safe => true) + # # => "

Once upon a time in a wo..." + # + # truncate("

Once upon a time in a world far far away

".html_safe) + # # => "

Once upon a time in a wo..." + # # You can still use truncate with the old API that accepts the # +length+ as its optional second and the +ellipsis+ as its # optional third parameter: