Skip to content

Latest commit

 

History

History
21 lines (14 loc) · 529 Bytes

conditional-class-selectors-in-haml.md

File metadata and controls

21 lines (14 loc) · 529 Bytes

Conditional Class Selectors in Haml

You can assign a class selector to a tag in HAML like so:

%div.active

You can conditionally assign a class selector in a concise manner like so:

%div{ class: ( "active" if @thing.active? ) }

You can do multiple conditional class selectors with array syntax:

%div{ class: [ ("active" if @thing.active?), ("highlight" if @thing.important?) ] }

source