Orsay Orsay - 19 days ago 6
Ruby Question

Conditional class in slim with 3 conditions

I would like to write conditional class in slim but I only know how to do it with 2 conditions, like :

div class=(index == 0 ? 'class1' : 'class1 class3')


How to do it with three conditions?

- if index == 0
.class1
- elsif index == -1
.class2.class3
- else
.class1.class3

Answer
div class=(if index == 0 then 'class1' elsif index == -1
then 'class2 class3' else '.class1 class3' end)
Comments