I have a list of items in a table. Some are true and some are false. Is there a way that the true elements can have one background colour whilst the false elements have another. I was considering writing a method in the application helper but I am not sure how is best to write this. So far all i have is
%td.success= person.success
This currently prints out true or false to the table but i would just like to add some background colour to this?
Or why not something like this:
css
td.success { background-color: 'green' }
td.failure { background-color: 'red' }
then in the haml
%td{class: "#{person.success ? 'success' : 'failure'}"} = person.success
Or
- if person.success
%td.success = person.success
- else
%td.failure = person.success
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With