I have a condition where if action_name contains “index” then the second class should return “index” only, otherwise, set it to action_name.
I was trying something along these lines:
- if action_name =~ /.*index.*/
%body{ :class => "#{controller_name} index" }
- else
%body{ :class => "#{controller_name} #{action_name}" }
Unfortunately I have the remainder of my body in the layout that follows these and it is only displayed for the else clause.
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.
Well, here’s a one liner:
Not that readable though!