Thursday, June 10, 2010

[Rails] Re: Hi, how can I split line length in Rails?

However thank you all,
I found solution, I write few lines in posts helper and everything
works fine
module PostsHelper
def wrap(content)
content.split.map{ |s| wrap_long_string(s) }.join(' ')
end

private

def wrap_long_string(text, max_width = 30)
zero_width_space = "​"
regex = /.{1,#{max_width}}/
(text.length < max_width) ? text :

text.scan(regex).join(zero_width_space)
end

end

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate