Append class if condition is true in Haml

后端 未结 5 1484
温柔的废话
温柔的废话 2020-11-30 17:50

If post.published?

.post
  / Post stuff

Otherwise

.post.gray
  / Post stuff

I\'ve implemente

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-30 18:53

    Updated Ruby syntax:

    .post{class: ("gray" unless post.published?)}
    

提交回复
热议问题