diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2010-06-13 06:11:23 -0300 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2010-06-13 06:11:23 -0300 |
commit | 27f337d54faa72a4d14f26fbfa5b0a1d5c28d44c (patch) | |
tree | a0aef5d57e642dc5ede313b906cf14d7c95e9ffa /actionpack/lib/action_view | |
parent | 8d1b74297978db97d7df7ceab59f8af94e370831 (diff) | |
download | rails-27f337d54faa72a4d14f26fbfa5b0a1d5c28d44c.tar.gz rails-27f337d54faa72a4d14f26fbfa5b0a1d5c28d44c.tar.bz2 rails-27f337d54faa72a4d14f26fbfa5b0a1d5c28d44c.zip |
truncate documentation an examples added for :safe option
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/text_helper.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb index 700c0b9e3b..cefabd72aa 100644 --- a/actionpack/lib/action_view/helpers/text_helper.rb +++ b/actionpack/lib/action_view/helpers/text_helper.rb @@ -39,6 +39,7 @@ module ActionView # for a total length not exceeding <tt>:length</tt>. # # Pass a <tt>:separator</tt> to truncate +text+ at a natural break. + # Pass a <tt>:safe</tt> (which defaults to false) to escape or not the input. If :safe => true the input is not escaped. # # ==== Examples # @@ -54,6 +55,15 @@ module ActionView # truncate("And they found that many people were sleeping better.", :length => 25, :omission => '... (continued)') # # => "And they f... (continued)" # + # truncate("<p>Once upon a time in a world far far away</p>") + # # => "<p>Once upon a time i..." + # + # truncate("<p>Once upon a time in a world far far away</p>", :safe => true) + # # => "<p>Once upon a time in a wo..." + # + # truncate("<p>Once upon a time in a world far far away</p>".html_safe) + # # => "<p>Once upon a time in a wo..." + # # You can still use <tt>truncate</tt> with the old API that accepts the # +length+ as its optional second and the +ellipsis+ as its # optional third parameter: |