title: How to use an if statement in HAML to control a tag class string?
body: <p>I have a condition where if action_name contains "index" then the second class should return "index" only, otherwise, set it to action_name.</p>
  
  <p>I was trying something along these lines:</p>
  
  <pre><code>  - if action_name =~ /.*index.*/
      %body{ :class =&gt; "#{controller_name} index" }
    - else
      %body{ :class =&gt; "#{controller_name} #{action_name}" }
  </code></pre>
  
  <p>Unfortunately I have the remainder of my body in the layout that follows these and it is only displayed for the <code>else</code> clause.  </p>
  
  <p>I figure there is a more readable one liner that I could use here as well that would perform an if within the line vs the more verbose multiline if statement, but I could use some help here in terms of gettin this to work as expected in HAML.</p>