Rajat
Rajat

Reputation: 1836

if else loop in haml

I have a haml code which looks something like this (it is more complicated than this, so this method is my only way out). This is using the twitter bootstrap framework.

-if <condition>
  .tab-pane.big-tab-pane.active#profile_pane
-else
  .tab-pane.big-tab-pane#profile_pane

  .. followed by the tab-pane code.

Now the thing is that this code is only invoked as part of the else loop, and not part of the if loop because the indentation is with the else loop part. How to make this work with haml so that the only the .active part is modified using the if/else clause and not the other pane HTML.

Upvotes: 0

Views: 402

Answers (1)

Chris Heald
Chris Heald

Reputation: 62638

Try using:

.tab-pane.big-tab-pane{:class => ("active" if condition)}

Upvotes: 2

Related Questions