#rails #haml

Rails Append class if condition is true in Haml

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

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

Qihuan Piao

Qihuan Piao

Originally from China and now living in Tokyo, I started this blog to practice English. Over the years, writing helped me find my own voice and explore thoughts about identity, life, and ordinary things that catch my curiosity. I mostly write for myself, but I love it when something here connects with someone else.

Meanwhile, what I wrote in Japanese

2012年の目標

January 1, 2012