Velocityビューでテーブルの1行ごとに色を付けたい

しばらくWebWork2のTipsを紹介していってみます。
まずは、VeocityビューでのTipsですが、テーブルの1行ごとに色を付ける方法。


まずはVelocityのループ変数に応じて、cssのクラス名を切り替える部品を作ります。
oddeven.vm

#if($velocityCount % 2 == 0) class="odd"#else class="even"#end"

使い方はループの中で、次のようにするだけです、簡単でしょ?
list.vm

<table>
#foreach($items in $action.Items)
  <tr #parse("oddeven.vm")>
    <td>$item.name</td>
  </tr>
#end
</table>