我认为以下内容:
- if (condition)
%div.truecondition
(Ten lines of content)
- else
%div.falsecondition
(Ten lines of the same content)
我想将内容的十行排除在if/else语句之下...但是,如果这样做,缩进意味着内容将不会嵌套在if/else中指定的div内。我确定这是一个普遍的问题,我只是想知道解决方案是什么。那么...我如何在保留内容嵌套在.truecondition/.falsecondition div中的同时剔除这十行呢?
最佳答案
您可以尝试Ternary operator:
%div{ :class => condition ? 'truecondition' : 'falsecondition' }
(Ten lines of content)
关于ruby-on-rails-3 - HAML:缩进具有共同内容的if/else语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6147610/