Erwin
2012-May-16 15:25 UTC
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 : <tr> <td colspan="2">Adresse</td> <td colspan="2"> 92, Place Honoré d''Urfé 35140, La Chapelle-Saint-Aubert </td> </tr> 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 <br> tags ?? thanks for feedback -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Scott Ribe
2012-May-16 15:45 UTC
Re: How to display a string the way it was entered ( w return new line)
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 Ribe scott_ribe-ZCQMRMivIIdUL8GK/JU1Wg@public.gmane.org http://www.elevated-dev.com/ (303) 722-0567 voice -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jeremy Walker
2012-May-16 15:47 UTC
Re: How to display a string the way it was entered ( w return new line)
On 16 May 2012 16:25, Erwin <yves_dufour-ee4meeAH724@public.gmane.org> wrote:> 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 : > <tr> > <td colspan="2">Adresse</td> > <td colspan="2"> > 92, Place Honoré d''Urfé > 35140, La Chapelle-Saint-Aubert > </td> > </tr> > 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 <br> tags ?? > >I''ve always used gsub. I normally have a function called nl2br that''s just gsub("\n", ''<br/>'') . In my views I just call = nl2br(address)> thanks for feedback > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Erwin
2012-May-16 16:14 UTC
Re: How to display a string the way it was entered ( w return new line)
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... On May 16, 5:47 pm, Jeremy Walker <jez.wal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 16 May 2012 16:25, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> wrote: > > > > > > > > > > > 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 : > > <tr> > > <td colspan="2">Adresse</td> > > <td colspan="2"> > > 92, Place Honoré d''Urfé > > 35140, La Chapelle-Saint-Aubert > > </td> > > </tr> > > 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 <br> tags ?? > > I''ve always used gsub. I normally have a function called nl2br that''s just > gsub("\n", ''<br/>'') . In my views I just call = nl2br(address) > > > > > > > > > thanks for feedback > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Jeremy Walker
2012-May-16 20:03 UTC
Re: Re: How to display a string the way it was entered ( w return new line)
On 16 May 2012 17:14, Erwin <yves_dufour-ee4meeAH724@public.gmane.org> 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.> > On May 16, 5:47 pm, Jeremy Walker <jez.wal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On 16 May 2012 16:25, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> wrote: > > > > > > > > > > > > > > > > > > > > > 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 : > > > <tr> > > > <td colspan="2">Adresse</td> > > > <td colspan="2"> > > > 92, Place Honoré d''Urfé > > > 35140, La Chapelle-Saint-Aubert > > > </td> > > > </tr> > > > 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 <br> tags ?? > > > > I''ve always used gsub. I normally have a function called nl2br that''s > just > > gsub("\n", ''<br/>'') . In my views I just call = nl2br(address) > > > > > > > > > > > > > > > > > thanks for feedback > > > > > -- > > > 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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm > . > > > To unsubscribe from this group, send email to > > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > For more options, visit this group at > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Erwin
2012-May-17 08:23 UTC
Re: How to display a string the way it was entered ( w return new line)
Thanks a lot for feedback... On May 16, 10:03 pm, Jeremy Walker <jez.wal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 16 May 2012 17:14, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> 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. > > > > > > > > > > > On May 16, 5:47 pm, Jeremy Walker <jez.wal...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On 16 May 2012 16:25, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> wrote: > > > > > 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 : > > > > <tr> > > > > <td colspan="2">Adresse</td> > > > > <td colspan="2"> > > > > 92, Place Honoré d''Urfé > > > > 35140, La Chapelle-Saint-Aubert > > > > </td> > > > > </tr> > > > > 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 <br> tags ?? > > > > I''ve always used gsub. I normally have a function called nl2br that''s > > just > > > gsub("\n", ''<br/>'') . In my views I just call = nl2br(address) > > > > > thanks for feedback > > > > > -- > > > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > > For more options, visit this group at > > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.