Conditional class in slim with 3 conditions

六月ゝ 毕业季﹏ 提交于 2021-01-28 22:17:43

问题


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

回答1:


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


来源:https://stackoverflow.com/questions/40591084/conditional-class-in-slim-with-3-conditions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!