Rails Append class if condition is true in Haml

.post{ :class => ('gray' unless post.published?) }

HAMLである条件がtrueの時だけあるclassをタグに追加したい場合。

November 22, 2011 Rails, haml

Share on Twitter Share
Qihuan Piao

Qihuan Piao

(aka kinopyo) is Chinese based in Tokyo. Software writer. He shares stories inspired him in this blog. His infamous line - "I feel calm when I kill those monsters, or people (in game)" shocks his friends deeply.
He also writes in Japanese and Chinese.