If you pass an array to haml it will join the values with spaces:
%a{:class => ["foo", "bar", "baz"]}
=> <a class="foo bar baz"></a>
If one of the values is nil, it is handled for you.
%a{:class => ["foo", ("bar" if false), "baz"]}
=> <a class="foo baz"></a>
This behavior plus helpers is very useful and doesn't require improvement,
IMO.
chris
On Wed, Aug 25, 2010 at 6:19 AM, Bogdan Gusiev <[email protected]> wrote:
> When I have conditional classes like: "disabled" if
> @user.followable_by?(current_user) mixed with static classes like:
> "big-blue-button". I want to be able to specify them as hash like:
>
> %a{:class => {:disabled => [email protected]_by?(current_user), :big-
> blue-button => true}}
>
> Keys of the hash tells class name and values tell when class should be
> included.
>
> I think it's better than construct this hash as array by hands.
>
> --
> 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] <haml%[email protected]>.
> For more options, visit this group at
> http://groups.google.com/group/haml?hl=en.
>
>
--
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.