Reputation: 2735
I am new to web dev. Below i have a code in haml
%th
%a#title_header
%a{:th => ("hilite" if @sort == "title")}= link_to 'Movie Title', :sort => "title"
which gives me the following HTML
<th>
<a id='title_header'>
<a th='hilite'><a href="/movies?sort=title">Movie Title</a></a>
</a>
</th>
While what i am looking to get is
<th class='hilite'>
<a id='title_header'><a href="/movies?sort=title">Movie Title</a></a>
</th>
Upvotes: 0
Views: 441
Reputation: 4187
This is very similar question with my answer: Adding dynamic attributes to HAML tag using helper method in rails
In your case it should be like:
%th{:class => if @sort == 'title' then 'hilite' end}
%a#title_header
%a= link_to 'Movie Title', :sort => "title
Upvotes: 1
Reputation: 10002
%th.hilite
%a#title_header
%a{:href => "/movies?sort=title"} Movie Title
by the way there's a project called http://html2haml.heroku.com/ check it out !
Upvotes: 1