randombits
randombits

Reputation: 48460

Embed HAML variable using Ruby interpolation

Not sure what I'm doing wrong here, but here's a small excerpt from my HAML template:

- player = log.player
%tr#player-row-#{player.id}

This is giving me the following error:

Illegal element: classes and ids must have values.

Am I embedding it wrong?

Upvotes: 1

Views: 252

Answers (2)

user229044
user229044

Reputation: 239302

As an alternative, you can use the slightly more succinct () form of attribute specification:

%tr(id="player-row-#{log.player.id}")

Upvotes: 1

Maurício Linhares
Maurício Linhares

Reputation: 40333

You can do it like this:

- player = log.player
%tr{:id => "player-row-#{player.id}"}

Upvotes: 3

Related Questions