Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
def truncate_on(text, length = 30, truncate_string = '...', separator = nil) return text unless text.respond_to?(:split) && text.length > 0 if separator new_text = text.split(separator)[0...length].join(separator) new_text == text ? new_text : new_text + truncate_string else truncate(text, length, truncate_string) end end
This paste will be private.
From the Design Piracy series on my blog: