title: Slightly different content many Rails views - how to be DRY
body: <p>Hopefully I haven't duplicated a question.  It's similar to <a href="https://stackoverflow.com/questions/8552763/best-way-to-highlight-current-page-in-rails-3-apply-a-css-class-to-links-con">this one</a> and <a href="https://stackoverflow.com/questions/14279258/rails-drying-similiar-but-different-views">this one</a> but not quite.</p>
  
  <p>On the subject of duplication, this is my problem.  I'm new to Rails btw.</p>
  
  <p>I have a (Twitter Bootstrap) set of pills/tabs and I want the <code>&lt;li&gt;</code> class to be set to <code>"active"</code> if the user is on the page associated with that tab.  So far I'm doing it a stupid way.. in each of my views I have this (simplified):</p>
  
  <pre><code>&lt;% content_for :pills do %&gt;
    &lt;li&gt;&lt;a href="/"&gt;Home&lt;/a&gt;&lt;/li&gt;
    &lt;li class="active"&gt;&lt;a href="/about"&gt;About&lt;/a&gt;&lt;/li&gt; &lt;----------- active class
    &lt;li&gt;&lt;a href="/contact"&gt;Contact&lt;/a&gt;&lt;/li&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>and in each view I have the same code (doh) but with the class set to <code>"active"</code> on another tab/pill.</p>
  
  <p>Most tab content comes from the same <code>app/views/&lt;some view directory&gt;/</code> but one tab comes from <code>app/views/&lt;some OTHER view directory&gt;/</code> but I guess this isn't a problem.</p>
  
  <p>How do I solve this without repeating similar code in each view?</p>
  
  <p>Many thanks.</p>