If statement with code on same block in haml, RoR

Posted by Micke on Stack Overflow See other posts from Stack Overflow or by Micke
Published on 2010-03-29T16:33:57Z Indexed on 2010/03/29 16:43 UTC
Read the original article Hit count: 533

Filed under:
|
|

Hello, i have this Haml view:

!!! strict
 %html{:xmlns => "http://www.w3.org/1999/xhtml"}
   %head
     %meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
     %title
       Lighty | #{@page_title || "Home"}
   %body
     #popup Login here
     #fade
     #wrapper
       #container
         #header
           %a#logo{:href => "/"}
         #menu
           %ul#main
             %li#lighty
               %a{:href => "/"} Lighty
                 %ul
                    %li
                       %a Link here
             %li#community
               %a{:href => "/community"} Community
        #content

And i would like to add an if on line #16 to check if it is the currently visited page and add the class "active" to the li if it returns true. How do i write that if statement there and is there any easier way to do this? My plan now is to use a variable like @current_page and testif it @current_page == "community" and add a class if it returns right. Am i thinking wrong? any easier way to accomplish this?

Thanks for your answer and sorry for my bad english.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about ruby-on-rails