たとえば、こんなことをやりたいとき
table
thead
tr
th name
th age
tbody
- @users.each do |u|
- if u.age >= 20
tr.info
td = u.name
td = u.age
- else
tr.danger
td = u.name
td = u.age
これは、ダサいですね。
こう書くと、ちょっとクールですね。
table
thead
tr
th name
th age
tbody
- @users.each do |u|
- klass = (u.age) >= 20) ? 'info' : 'danger'
tr class="#{klass}"
td = u.name
td = u.age
もっとよい書き方ありそう。
class の条件が増えていったら大変そうだ。