>> Philip Hallstrom wrote in post #978930:
>>> I went ahead and wrote the patch and submitted it with comments about
>>> the change in behavior.  I could always add a "strip" option to get what
>>> I want.
>>> 
>>> If anyone is interested...
>>> 
>>> 
>> 
> https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6357-patch-to-remove-trailing-spaces-from-truncate-result
>> 
>> This might be fine for English (or English like) strings, but not all
>> language necessarily separate words by space characters.

I'm not sure that matters.  I don't mind if "Hello World" gets truncated to 
"Hel...".  I do mind (from an aesthetics point of view) "Hello ..."...

>> Truncate is not strip. It probably should not make this assumption.

Perhaps not.  But there's no other way to clean that up which means I'd have to 
write my own truncate method which also seems wrong.  :/

> Oh! I forgot to mention that truncate already includes the :separator 
> option:
> 
> truncate("Once upon a time in a world far far away", :length => 17, 
> :separator => ' ')

That will force the break on a space.  I don't necessarily want that either.

All valid though.  We'll see what core says on the ticket.  If they prefer I 
add a :strip => true option I'm fine with that as it gets me what I want 
without changing defaults...

-philip

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to