ViewFu plugin has some pretty cool haml helpers for this.
http://github.com/neorails/view_fu

%li{add_class_if('active', @my_account)} #=> <li class="active">
%li.account{add_class_if('active', @my_account)} #=> <li
class="account active"

Here's some additional syntactic sugar it provides:
%li{hidden} #=> <div style="display:none">
%li{hidden_if(true)} #=> <div style="display:none">
%li{hidden_unless(false)} #=> <div style="display:none">

there's also show_if, show_unless which are just opposite wrappers

- @accounts.each_with_index do |account, index|
  %li{is_first(index)}

will display the .first class for the first one in the list


On Nov 22, 1:16 pm, deadwards <[EMAIL PROTECTED]> wrote:
> Chris,
>
> Awesome.  Thanks for the help, that worked perfectly!
>
> On Nov 21, 1:14 pm, Chris Eppstein <[EMAIL PROTECTED]> wrote:
>
> > This should work:
>
> > %li{:class => ('active' if @my_account)}= link_to "My Account",
> > account_path(@my_account)
>
> > chris
>
> > On Nov 21, 8:13 am, deadwards <[EMAIL PROTECTED]> wrote:
>
> > > I am relatively new to Haml, and have a question.  Is it possible to
> > > include rails code inside of an html tag?
>
> > > Here is the erb code that I'm trying to convert to Haml:
> > > <code><pre>
> > > <li<%= " class='active'" if @my_account %>><%= link_to "My Account",
> > > account_path(@my_account) %></span></li>
> > > </pre></code>
>
> > > Thanks for any help.
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Haml" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to