Newline in string ...

Hello,

The following is a toggle div, in which I'm trying to add a newline after the word 'notes:'

<%= content_tag(:div, content_tag(:p, "Our programme notes are being prepared.", :class => 'regtextend'), :id => 'notes') %>

And this doesn't work:

<%= content_tag(:div, content_tag(:p, "Our programme notes\nare being prepared.", :class => 'regtextend'), :id => 'notes') %>

When using simple_format, \n breaks the line. I see that it wouldn't work the same way, but is there a way to escape in the middle of a string in this case? Help would be appreciated! Thanks -- Jon.

Why would it? is html what gets rendered, use
and end the string with html_safe

Try something like this

<%= content_tag(:div, content_tag(:p, "Our programme notes are being

prepared.
", :class => ‘regtextend’), :id => ‘notes’).html_safe %>

Or <%= raw content_tag(:div, content_tag(:p, "Our programme notes are being

prepared.
", :class => ‘regtextend’), :id => ‘notes’).html_safe %>

I couldn't actually get it to work, but good to learn about html_safe! I ended up with:

<%= content_tag(:div, simple_format("Our programme notes\nare being prepared.", :class => 'regtextend'), :id => 'notes') %>

Not sure if that's the best solution, but it works well. Thanks again for the help -- Jon.