ale
ale

Reputation: 11820

Converting view from ERB to HAML to print HTML class

I have this ERB:

<li class="<%= pill_class_for(:home, :index) %>"><a href="/">Home</a></li>

pill_class_for is a is a helper function that returns a string representing a HTML class. How can I change this to HAML?

I tried this but it's stupid and doesn't work:

%li.= pill_class_for(:home, :index)<a href="/">Home</a>

You can see what I'm trying to do above but it results in a SyntaxError (Illegal element: classes and ids must have values.).

Many thanks.

Upvotes: 1

Views: 67

Answers (1)

Lu&#237;s Ramalho
Lu&#237;s Ramalho

Reputation: 10208

Try the following

%li{:class => pill_class_for(:home, :index)}
  %a{:href => "/"} Home

Upvotes: 2

Related Questions