if then else in HAML?

7,219 views
Skip to first unread message

sbtodd

unread,
Nov 16, 2007, 2:00:15 AM11/16/07
to Haml
I could not find any example of how to replace something like
this that is common in RHTML

<% if @user.logged_in? %>
YOU ARE LOGGED IN
<% else %>
LOG IN OR SIGN UP
<% end %>

How can you do that with HAML??

Thanks

Nathan Weizenbaum

unread,
Nov 16, 2007, 3:42:08 AM11/16/07
to ha...@googlegroups.com
- if @user.logged_in?
YOU ARE LOGGED IN
- else

LOG IN OR SIGN UP

No end required. For future reference, this is covered in
http://haml.hamptoncatlin.com/docs/ :-).

sbtodd

unread,
Nov 16, 2007, 11:49:05 AM11/16/07
to Haml
Thanks.

I tried that but was using: - end .. should have realized
that the - end was not needed and indentation took care of it.

I was looking in http://haml.hamptoncatlin.com/docs/haml
and could not find how to do conditionals.

Maybe you could add a Conditional Execution section to the docs
with this simple example. : )

Thanks a lot for your help. This stuff is great!

Todd

On Nov 16, 12:42 am, Nathan Weizenbaum <nex...@gmail.com> wrote:
> - if @user.logged_in?
> YOU ARE LOGGED IN
> - else
> LOG IN OR SIGN UP
>
> No end required. For future reference, this is covered inhttp://haml.hamptoncatlin.com/docs/:-).
Reply all
Reply to author
Forward
0 new messages