<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: helpers code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Mon, 06 Oct 2008 12:19:39 GMT</pubDate>
    <description>DZone Snippets: helpers code</description>
    <item>
      <title>Alternative zebra stripes approach using a helper</title>
      <link>http://snippets.dzone.com/posts/show/411</link>
      <description>This is a tidy way of alternating classes on some element.&lt;br /&gt;&lt;br /&gt;In the view:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;    &lt;tr class="&lt;%= alternate %&gt;"&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;In your application helper:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;def alternate(str1 = "odd", str2 = "even")&lt;br /&gt;   @alternate_odd_even_state = true if @alternate_odd_even_state.nil?&lt;br /&gt;   @alternate_odd_even_state = !@alternate_odd_even_state&lt;br /&gt;   @alternate_odd_even_state ? str2 : str1&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Wed, 22 Jun 2005 18:38:04 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/411</guid>
      <author>davidnorth (David North)</author>
    </item>
  </channel>
</rss>
