is there a way of cleaning rails' html output? by default, it looks
real ugly (in terms of indentation), and i don't know how people can
live with that. there is rails-tidy, and although it makes html really
pretty, setting it up involves some tricky workarounds, and the author
also commented:
"THIS IS CERTAINLY A RESOURCE HOG. I’m not interrested in this feature
so I didn’t benchmarked it but at first sight rendering is at least 2
times slower with the filter enabled."?
<opinion>
If it renders fine in a browser, who cares what it looks like under the
hood?
</opinion>
That being said, haml as a replacement for erb, produces some nicely
formatted html if you're into viewing page source. It may have been a
goal of the author, but I just like the cleaner forms I have to produce.
In all seriousness, I’ve been doing web programming for a long time. If I’m generating HTML from a web application, I just don’t care what the rendered HTML code looks like, and I can’t figure out why people do. This isn’t the first time I’ve seen this question, so am I missing something? If it validates, and it renders, then does it matter?
I just look at it in firebug to see the layout. Much easier that
dealing with the raw source and links the css nicely as well.
Fundamentally in Rails, it is how clean the ERB is to look at rather
than the HTML. You don't take a C program and then complain that the
assembler output from the compiler is not very pretty.
Now that's gorgeous. I know which I'd rather type.
You only need to use the hash braces if you're doing something more
conditional, and then you can just put it in a helper and call the
method
Agreed... my standard indentation in Rails (controllers, models,
helpers, etc) is 2 spaces, so doing that for the views is just second
nature (be it erb or haml)... but I'm a lazy bastidge at heart, so if
indentation can imply all those closing tags and the view code is less
for my poor brain to process, I'm all for it.