Alexandre
Alexandre

Reputation: 13308

Executing ruby code in haml element

Here is the haml code that doesn't work as I need

%table
[email protected] do |item|
 %tr{:class=>"=cycle('list_line_odd', 'list_line_even')"}

where cycle is a standard Rails method. The output html is

 <table>
  <tr class="cycle('list_line_odd', 'list_line_even')">

What should I do to solve it?

Upvotes: 0

Views: 228

Answers (1)

hs-
hs-

Reputation: 1026

%tr{:class=>cycle('list_line_odd', 'list_line_even')}

You need to get rid of double quotes so parser would read it like method call rather than string.

Upvotes: 3

Related Questions