Jeff Axelrod
Jeff Axelrod

Reputation: 28188

How can I set the CSS class of an element in a Rails view?

How can I set the class of an element in a Rails view's haml?

For example, suppose I want to set the CSS class of a %td% element that's written like this to the "red" class:

%td= book.author

How would this be written?

Upvotes: 1

Views: 140

Answers (1)

Chris Heald
Chris Heald

Reputation: 62638

That looks like Haml.

You can use either %td.red= book.author or %td{:class => "red"}= book.author.

Upvotes: 3

Related Questions