Ruby/html trick: wrap long strings with invisible wordwrap characters
def wrap_long_string(text,max_width = 20)
(text.length < max_width) ?
text :
text.scan(/.{1,#{max_width}}/).join(“<wbr>”)
end
I am a photographer, entrepreneur, software engineer, guitarist, and telemark skier
This blog is about startups, blogging, Ruby On Rails, virtualization and cloud computing, photography, customer service, marketing, ux and design, git, and lots more.
Reach me at yan at pritzker.ws
def wrap_long_string(text,max_width = 20)
(text.length < max_width) ?
text :
text.scan(/.{1,#{max_width}}/).join(“<wbr>”)
end
© Yan Pritzker. Powered by WordPress using a DePo Clean Theme modified by Yan Pritzker.