There're two helpers available to deal with this. They both work by
replacing newlines with the HTML character code for a newline, thus
avoiding Haml's auto-indentation while keeping the output relatively
nice-looking. The first is called "preserve", which just replaces all
newlines. The second is called "find_and_preserve", which replaces all
newlines within whitespace sensitive tags, like pre and textarea. So,
for example, you could do:
= find_and_preserve text_area_tag("foo", "bar\nbar\nbar")
There's also a shortcut for "= find_and_preserve": the ~ character.
~ text_area_tag "foo", "bar\nbar\nbar"
Hope that helps!
- Nathan
ridcully wrote:
> Hello,
>
> I have a quite serious problem with textareas and haml. Version is
> trunk (1.6.0). Consider the following:
>
> textarea_layout.haml
>
> %div
> = @content_for_layout
>
>
> textarea.haml
>
> = text_area_tag "foo", "bar\nbar\nbar"
>
>
> renders to:
>
> <div>
> <textarea id="foo" name="foo">bar
> bar
> bar</textarea>
> </div>
>
> As you can see, the content of the textarea is indented, resulting in
> leading whitespaces in each line of the textarea. This is not the case
> if I replace the \n newlines with \r carriage returns ("bar\rbar
> \rbar").
>
> I would really appreciate any input!
>
> Andi
>
>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Haml" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---