Haml, form_for and some other rails helpers formatting/indenting

937 views
Skip to first unread message

ludicco

unread,
Aug 31, 2009, 12:58:02 PM8/31/09
to Haml
Hello, first thing, congratulations for the beautiful job.
I really love deal with HAML instead raw xhtml development.

Well, I have a question:
Is there a proper way to format/indent that extra lines generated by
rails helpers such form_for?
for example:
---
- form_for @user do |f|
= f.label :name, "Your Name"

---generates--

<form action="/users" class="new_user" id="new_user"
method="post"><div style="margin:0;padding:0;display:inline"><input
name="authenticity_token" type="hidden" value="gOnWFvTBWpYHqfrwDuu66M/
Yi3JGfucxJx3m4WtnBKM=" /></div>
<label for="user_name">Your Name</label>
</form>

*note that the form, div and input are on the same line, no line
breaks

--and not--

<form action="/users" class="new_user" id="new_user" method="post">
<div style="margin:0;padding:0;display:inline">
<input name="authenticity_token" type="hidden"
value="gOnWFvTBWpYHqfrwDuu66M/Yi3JGfucxJx3m4WtnBKM=" />
</div>
<label for="user_name">Your Name</label>
</form>

--
This is nothing about the functionality because its perfect on this
side, its more aesthetic, since its one of the main reasons I use
HAML.

Thanks in advance

Nathan Weizenbaum

unread,
Sep 1, 2009, 12:00:24 AM9/1/09
to ha...@googlegroups.com
Haml does its best to re-format helpers like this to make them fit better with Haml's nice output. However, we can't go completely re-writing all the Rails helpers to make the output nice. Since form_for is a Rails helper, we can't go in and tweak how it generates the HTML to make it prettier, as much as we'd like it to be.
Reply all
Reply to author
Forward
0 new messages