I have this haml:
.kudobox
%div.kudos= number_to_human_size_not_bytes kudos
%div= (kudos == 1 || kudos == -1) ? "kudo" : "kudos"
Now I want the .kudobox
have a positive
, negative
or zero
class, depending on the number of kudos:
-# < 0 kudos
<div class="kudobox negative">
-# == 0 kudos
<div class="kudobox zero">
-# > 0 kudos
<div class="kudobox positive">
How can I achieve this? Thanks.
I know I can
%div{ :class => ( kudos < 0 ? "kudobox negative" : ( kudos == 0 ? "kudobox zero" : ( kudos > 0 ? "kudobox positive" : "kudobox impossible" ) ) ) }
But isn't there a shorter way?