This project is archived and is in readonly mode.
Augment truncate helper to accept a separator
Reported by Andy Stewart | January 28th, 2009 @ 04:56 PM | in 2.x
The truncate text helper currently cuts off the given text mid-word if that's where the length limit is reached.
This backwards-compatible patch allows you to pass the :separator option to make the truncated result end at the last occurrence of the given separator (within the length allowed).
If you don't pass the :separator option the helper behaves as it currently does. This means that all existing code will continue to work the same way.
Typically you would use this to have the truncated text finish at the end of a word.
For example:
truncate("Once upon a time in a world far far away")
=> Once upon a time in a world f...
truncate("Once upon a time in a world far far away", :separator => ' ')
=> Once upon a time in a world...
Comments and changes to this ticket
-
Andy Stewart February 2nd, 2009 @ 02:39 PM
- Title changed from Modify truncate helper to accept a separator to Augment truncate helper to accept a separator
-
Repository May 18th, 2009 @ 08:39 PM
- State changed from new to resolved
(from [5e190ef138a034bf86419ce4f4c343ae16bfc77b]) Truncate helper accepts a :separator for a more legible result [#1807 state:resolved]
Signed-off-by: Pratik Naik pratiknaik@gmail.com
http://github.com/rails/rails/commit/5e190ef138a034bf86419ce4f4c343...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 1807 Augment truncate helper to accept a separator (from [5e190ef138a034bf86419ce4f4c343ae16bfc77b]) Truncat...