How to display a string the way it was entered ( w return new line)

On input in a text area, the user can se the return key which generate
a \r\n inside the string
the address is stored per se the way it was keyed in …

@partner[:bank_location]
=> “92, Place Honor d’Urf\r\n35140, La Chapelle-Saint-Aubert”

When displaying it inside a table cell, the \r\n is ignored , and the
generated html is :


Adresse

92, Place Honor d’Urf
35140, La Chapelle-Saint-Aubert


but it’s not displayed like that …
I rather get :
Adresse 92, Place Honor d’Urf 35140, La Chapelle-
Saint-Aubert

Is there a way to modify this behavior or should I gsub the string to
insert html
tags ??

thanks for feedback

On May 16, 2012, at 9:25 AM, Erwin wrote:

Is there a way to modify this behavior…

No, there is no way to modify “this behavior” of how the HTML standard
treats, and has always since day 1 treated, whitespace.


Scott R.
[email protected]
http://www.elevated-dev.com/
(303) 722-0567 voice

On 16 May 2012 16:25, Erwin [email protected] wrote:

                     <td colspan="2">Adresse</td>

Is there a way to modify this behavior or should I gsub the string to
insert html
tags ??

I’ve always used gsub. I normally have a function called nl2br that’s
just
gsub(“\n”, ‘
’) . In my views I just call = nl2br(address)

OK thanks , thats’ what I thought initially… as you defined a
function … and I’ll define a function … and many others have done
before us … this could have been defined in the core String class…

Thanks a lot for feedback…

On 16 May 2012 17:14, Erwin [email protected] wrote:

OK thanks , thats’ what I thought initially… as you defined a
function … and I’ll define a function … and many others have done
before us … this could have been defined in the core String class…

I just went to write this and discovered there’s a helper
called simple_format that does exactly the same thing.