If you pass an attribute a nil value, it won't render. Thus you can do
something like
.my_class{:id => "my_id", :style => hidden ? 'display: none' : nil}
- Nathan
KJoyner wrote:
> Within my haml template, I was trying to add a :style => 'display:
> none' to a div depending on a ruby local variable being passed into my
> haml template.
>
> I am able to do this with the following code but it only works if
> there are no other attributes:
>
> .my_class{ hidden ? { :style => 'display: none' } : {} }
>
> However, if I have other attributes such as :id => then I cannot get
> it to work. For example,
> .my_class{ :id => "my_id", hidden { :style => 'display: none' }}
> does not work
>
> I also tried the following but could not get it to work
>
> - class_attributes = { :id => "my_id" }
> - if hidden
> class_attributes.merge( { :style => 'display: none' })
>
> Thanks for any help,
>
> -- Ken
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---