Haml doesn't print attributes with value nil. The problem here is that 
cycle always returns a string, so you're actually cycling between "" and 
"alt_table_row". The solution is to make Haml treat empty attributes the 
same way it treats nil attributes, which I think is reasonable behavior, 
and which I just added to trunk. If you want to stick with stable, then 
I would say make a helper that wraps cycle:

def cycle_with_nils(first_value, *values)
  result = cycle(first_value, *values)
  result.empty? ? nil : result
end

and use

%tr{ :class => cycle_with_nils(nil, 'alt_table_row') }

- Nathan

shaners wrote:
> i want to end up with this:
>
> <tr></tr>
> <tr class='alt_table_row'></tr>
>
> the best i could figure out is to do this:
>
> %tr{ :class => cycle(nil, 'alt_table_row') }
>
> but that leaves me with this on the rows that should have no class:
>
> <tr class=''></tr>
>
>
> is there a way to do this without doing a hash with a class in it?

--~--~---------~--~----~------------~-------~--~----~
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