kinopyo blog Learning through Writing
English 日本語 中文
Archives About
    In other words
  • English
  • 日本語
  • 中文
Archives About
November 22, 2011 #rails #haml

Rails Append class if condition is true in Haml

Append class if condition is true in Haml (with Rails) - Stack Overflow http://t.co/7pyL7pNn

— kinopyo (@fantasyday) November 22, 2011

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

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

This website is built by Qihuan Piao with Rails, hosting on Heroku.

Copyright © 2009 - 2025 Qihuan Piao