On 9/14/06, s.ross [email protected] wrote:
<%= foo.name %>
<% end %>
That was a difficult early decision to make. At first, it was something
I planned to add. But, then as we began to use it on our projects
of them so far) we found that not having if, loops, and blocks is
a good thing.
Our code ends up being more readable, and it forces us to make
decisions on whether the bit of wanted functionality should be a
helper, or a one-line-loop. Generally, this means that the code is far
You’d say this
and go put that in the helpers.
I.e., how do you stick raw Ruby in without the results being inserted in
Well, in general, that code should be in the view, assuming that it
doesn’t return a result.
However, if you want a hacky way…
= action_with_no_result && nil
Any line that returns a nil will not print… that’s including tags.
It can be helpful when you want a wrapping div and you’d like to supress
- What is the ~ character for? I saw it in the tests and the plugin
but not sure what it does.
Well, the biggest problem with auto-indenting code are those pesky
, and tags. In all of HTML, they are the only ones who
don't want to be indented or you get wonky results.
I spent more time on this issue than on any other in building HAML. I
fill a book with my thoughts on it and my struggles. However, after
to some very smart people and doing lots of consideration, this was the
First, ~ simply says "hey, watch out, you might be given some whitespace
sensitive stuff coming into you from the evaluation on the right". But,
it does is causes some processing that changes "\n" into the UTF-8
for endlines. Basically, it puts the whole tag on one line, but puts in
endline character that the browser can respect, but won't mess up your
It keeps the output beautiful and doesn't hurt anything. Also, it saves
processing to only have to specify where it might happen.
3. How would designers work with this?
Our designer loves it. They don't really care about HTML, they care
understanding the structure of the page. Also, they go crazy for the CSS
Funny story, Anthony, the guy who posted below, he wouldn't work the
day because we didn't install haml on a project. He now refuses to work
any projects that don't use HAML. Simply because he likes the syntax and
way it helps him think about the pages structure. Honestly, I am super
surprized by this outcome, but it speaks a lot to what our problems have
been so far.