# Odd text formatting on edit

**URL:** <https://www.ruby-forum.com/t/odd-text-formatting-on-edit/132718>\
**Category:** Rails\
**Created:** [March 24, 2008, 12:29am UTC](https://www.ruby-forum.com/t/odd-text-formatting-on-edit/132718 "2008-03-24T00:29:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sumwutdum](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@sumwutdum](https://www.ruby-forum.com/u/sumwutdum)\
**Post date:** [March 24, 2008, 12:29am UTC](https://www.ruby-forum.com/t/odd-text-formatting-on-edit/132718/1 "2008-03-24T00:29:37Z")

</div>

I have never had this problem in any previous projects, but for some  
reason all text\_area inputs that contain a new line result in a huge  
indent

## ex

|Hello  
|World  
|  
|

| |
| --- |

## results in when editting

|Hello  
| World  
|  
|

| |
| --- |

I have stripped out all text formatting on record saves, as well as  
formating when filling the text box.

Has anyone seen this before?

Thanks

---

<div class="post-metadata">

**Author:** ![sumwutdum](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@sumwutdum](https://www.ruby-forum.com/u/sumwutdum)\
**Post date:** [March 24, 2008, 2:07pm UTC](https://www.ruby-forum.com/t/odd-text-formatting-on-edit/132718/2 "2008-03-24T14:07:51Z")

</div>

If you aren’t using haml, ignore this.

If you are using haml, this can happen due to how haml formats its  
ouput.

To fix this in haml, tweak to your haml statement in the view to use the  
tilde instead of an equals when defining text areas, like the proj\_text  
field below:

%hr/

- form\_for @project do |f|  
%table  
%tr  
%td= Project:  
%td= f.text\_field :proj\_name, :size =\> 30  
%tr  
%td Description:  
%td= f.text\_field :proj\_desc, :size =\> 120  
%tr  
%td Notes:  
%td~ f.text\_area :proj\_text, :cols =\> 90, :rows =\> 20  
%hr/  
%table  
%tr  
%td= f.submit “Save”

---

<div class="post-metadata">

**Author:** ![sumwutdum](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@sumwutdum](https://www.ruby-forum.com/u/sumwutdum)\
**Post date:** [March 24, 2008, 3:18am UTC](https://www.ruby-forum.com/t/odd-text-formatting-on-edit/132718/3 "2008-03-24T03:18:19Z")

</div>

Iso,

If you’re generating the text\_area contents from rails you may want to  
try  
suppressing the new line when closing your ERb phrases like this:

\<%= Time.now -%\>

instead of

\<%= Time.now %\>

Just an idea.

Arshak

iso … wrote:

> I have never had this problem in any previous projects, but for some  
> reason all text\_area inputs that contain a new line result in a huge  
> indent
> 
> ## ex
> 
> |Hello  
> |World  
> |  
> |
> 
> | |
> | --- |
> 
> ## results in when editting
> 
> |Hello  
> | World  
> |  
> |
> 
> | |
> | --- |
> 
> I have stripped out all text formatting on record saves, as well as  
> formating when filling the text box.
> 
> Has anyone seen this before?
> 
> Thanks

---

<div class="post-metadata">

**Author:** ![sumwutdum](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b77776/32.png) [@sumwutdum](https://www.ruby-forum.com/u/sumwutdum)\
**Post date:** [March 24, 2008, 9:07pm UTC](https://www.ruby-forum.com/t/odd-text-formatting-on-edit/132718/4 "2008-03-24T21:07:04Z")

</div>

Ar Chron wrote:

> If you aren’t using haml, ignore this.
> 
> If you are using haml, this can happen due to how haml formats its  
> ouput.
> 
> To fix this in haml, tweak to your haml statement in the view to use the  
> tilde instead of an equals when defining text areas, like the proj\_text  
> field below:
> 
> %hr/
> 
> - form\_for @project do |f|  
> %table  
> %tr  
> %td= Project:  
> %td= f.text\_field :proj\_name, :size =\> 30  
> %tr  
> %td Description:  
> %td= f.text\_field :proj\_desc, :size =\> 120  
> %tr  
> %td Notes:  
> %td~ f.text\_area :proj\_text, :cols =\> 90, :rows =\> 20  
> %hr/  
> %table  
> %tr  
> %td= f.submit “Save”

I should have mentioned that I am using Haml this time around. That  
fixed the problem.

Thank you very much.
