Joshua Muheim
2008-Feb-17 19:05 UTC
HAML: %li{:class => ''current'' if page == 2} does not work?
Hi all I''m iterating over navigation page links using HAML. I want to assign the current page''s link the CSS class .current trying to use: %li{:class => ''current'' if params[:page] == i} Sadly this doesn''t work. How can I achieve the wanted result? Thanks for help, Josh -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
s.ross
2008-Feb-17 20:37 UTC
Re: HAML: %li{:class => ''current'' if page == 2} does not work?
On Feb 17, 2008, at 11:05 AM, Joshua Muheim wrote:> %li{:class => ''current'' if params[:page] == i}params are always returned as strings. Use params[:page].to_i == i or params[:page] == i.to_s. See if that works. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Joshua Muheim
2008-Feb-18 09:56 UTC
Re: HAML: %li{:class => ''current'' if page == 2} does not wor
Steve Ross wrote:> On Feb 17, 2008, at 11:05 AM, Joshua Muheim wrote: > >> %li{:class => ''current'' if params[:page] == i} > > params are always returned as strings. Use params[:page].to_i == i or > params[:page] == i.to_s. See if that works.Thanks, but I guess I wasn''t specific enough. ;-) My problem is that HAML throws an error when having an "if" statement within %li{...}. Isn''t it allowed to use them? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Peter
2008-Feb-18 10:05 UTC
Re: HAML: %li{:class => ''current'' if page == 2} does not wor
I use this line in HAML, and that works fine. %li{:class => ("active" if item[:item] == active_menu_item)} so maybe it''s the ( ) that do the trick? On Feb 18, 10:56 am, Joshua Muheim <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Steve Ross wrote: > > On Feb 17, 2008, at 11:05 AM, Joshua Muheim wrote: > > >> %li{:class => ''current'' if params[:page] == i} > > > params are always returned as strings. Use params[:page].to_i == i or > > params[:page] == i.to_s. See if that works. > > Thanks, but I guess I wasn''t specific enough. ;-) > > My problem is that HAML throws an error when having an "if" statement > within %li{...}. Isn''t it allowed to use them? > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Joshua Muheim
2008-Feb-18 10:26 UTC
Re: HAML: %li{:class => ''current'' if page == 2} does not wor
Peter wrote:> I use this line in HAML, and that works fine. > > %li{:class => ("active" if item[:item] == active_menu_item)} > > so maybe it''s the ( ) that do the trick? > > On Feb 18, 10:56 am, Joshua Muheim <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Yes, this seemed to be the problem. Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---