Hi!
Hope this is the right place (I’m not a Ruby on Rails user).
The Method ist defined as
(ActionView::Helpers::TextHelper):
def word_wrap(text, line_width = 80)
text.gsub(/\n/, “\n\n”).gsub(/(.{1,#{line_width}})(\s+|$)/,
“\1\n”).strip
end
The sense of the part ‘gsub(/\n/, “\n\n”)’ is not visible for me,
because
newlines will be removed in the next step by ‘\s+’.
I made some tests (Ruby, not Ruby on Rails) and couldn’t find any
difference to
the following definition:
def word_wrap(text, line_width = 80)
text.gsub(/(.{1,#{line_width}})(\s+|$)/, “\1\n”).strip
end
Wolfgang Nádasi-Donner