|
List Info
Thread: Class conditions in HAML
|
|
| Class conditions in HAML |
  United States |
2007-10-05 18:16:16 |
Hi,
We're trying to do something like:
%li.current= link_to_unless_current "All
Activity",
user_history_path( user)
But have the .current class given to the <li> element
only if they are
on user_history_path( user).
This is my best shot at it:
%li{:class => "#{'current' if current_page?
(user_profile_history_path( user_profile))}"}
= link_to_unless_current "All Activity",
user_history_path( user)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Haml" group.
To post to this group, send email to haml googlegroups.com
To unsubscribe from this group, send email to
haml-unsubscribe googlegroups.com
For more options, visit this group at http://grou
ps.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Class conditions in HAML |
  United States |
2007-10-05 18:18:40 |
Oops, I meant this for my best shot:
%li{:class => "#{'current' if current_page?
(user_history_path( user))}"}
= link_to_unless_current "All Activity",
user_history_path( user)
Joe
On Oct 5, 4:16 pm, Joe Van Dyk <joevan... gmail.com> wrote:
> Hi,
>
> We're trying to do something like:
>
> %li.current= link_to_unless_current "All
Activity",
> user_history_path( user)
>
> But have the .current class given to the <li>
element only if they are
> on user_history_path( user).
>
> This is my best shot at it:
>
> %li{:class => "#{'current' if current_page?
> (user_profile_history_path( user_profile))}"}
> = link_to_unless_current "All Activity",
user_history_path( user)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Haml" group.
To post to this group, send email to haml googlegroups.com
To unsubscribe from this group, send email to
haml-unsubscribe googlegroups.com
For more options, visit this group at http://grou
ps.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Class conditions in HAML |
  United States |
2007-10-05 18:25:46 |
Here's how I'd do it:
%li{:class => current_page?(user_history_path) ?
'current' : nil}
= link_to_unless_current "All Activity",
user_history_path( user)
- Nathan
Joe Van Dyk wrote:
> Oops, I meant this for my best shot:
>
> %li{:class => "#{'current' if current_page?
> (user_history_path( user))}"}
> = link_to_unless_current "All Activity",
user_history_path( user)
>
> Joe
>
>
> On Oct 5, 4:16 pm, Joe Van Dyk <joevan... gmail.com> wrote:
>
>> Hi,
>>
>> We're trying to do something like:
>>
>> %li.current= link_to_unless_current "All
Activity",
>> user_history_path( user)
>>
>> But have the .current class given to the <li>
element only if they are
>> on user_history_path( user).
>>
>> This is my best shot at it:
>>
>> %li{:class => "#{'current' if
current_page?
>> (user_profile_history_path( user_profile))}"}
>> = link_to_unless_current "All
Activity", user_history_path( user)
>>
>
>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Haml" group.
To post to this group, send email to haml googlegroups.com
To unsubscribe from this group, send email to
haml-unsubscribe googlegroups.com
For more options, visit this group at http://grou
ps.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Class conditions in HAML |

|
2007-10-05 18:40:29 |
On 10/5/07, Joe Van Dyk <joevandyk gmail.com> wrote:
>
> Hi,
>
> We're trying to do something like:
>
> %li.current= link_to_unless_current "All
Activity",
> user_history_path( user)
>
> But have the .current class given to the <li>
element only if they are
> on user_history_path( user).
If you're using this a lot (or more than a little), it might
be worth
writing a helper to handle it. It would keep your views nice
and
clean.
--
Chris Boone, Hypsometry
http://hypsometry.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Haml" group.
To post to this group, send email to haml googlegroups.com
To unsubscribe from this group, send email to
haml-unsubscribe googlegroups.com
For more options, visit this group at http://grou
ps.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
[1-4]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|