josh
1
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
josh
2
On Feb 17, 2008, at 11:05 AM, Joshua M. 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.
josh
3
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 M. [email protected]
josh
4
Steve R. wrote:
On Feb 17, 2008, at 11:05 AM, Joshua M. 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?
josh
5
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 M. [email protected]
Yes, this seemed to be the problem. Thanks.