HAML, Add class to image_tag

Mechwd picture Mechwd · Sep 10, 2011 · Viewed 16.9k times · Source

I have

= image_tag  "chart.jpg"

I am new to HAML so how do I add a class to this?

Answer

matt picture matt · Sep 10, 2011

Assuming this is rails (Haml doesn't have its own image_tag helper, but Rails does), then the second argument is an options hash where you can specify the class:

=image_tag  "chart.jpg", :class => "my_class"