title: loop in templates
body: <p>My template looks like:</p>
  
  <pre><code>  &lt;h2&gt;Oracle&lt;/h2&gt;
  
    &lt;% @q_oracle.each do |q| %&gt;
      &lt;%= link_to(q.title + ' (' + q.answer_count.to_s + ') ' + q.question_id.to_s, 'http://stackoverflow.com/' + q.question_answers_url) %&gt;  &lt;/br&gt;
  
    &lt;% end %&gt;
  
  
    &lt;h2&gt;Ruby and Rails&lt;/h2&gt;
  
    &lt;% @q_ruby.each do |q| %&gt;
      &lt;%= link_to(q.title + ' (' + q.answer_count.to_s + ') ' + q.question_id.to_s, 'http://stackoverflow.com/' + q.question_answers_url) %&gt;  &lt;/br&gt;
  
    &lt;% end %&gt;
  </code></pre>
  
  <p>So the temlate consists the static titles (h2) and loops through the array. I am searching the way to avoid copy-paste code in the my template.  Something like:</p>
  
  <pre><code>@hash = { 'Oracle' =&gt; @q_oracle, 'Ruby and Rails' =&gt; @q_ruby }
  
  @hash.each { |@t, @a|
  
    &lt;h2&gt;@t&lt;/h2&gt;
  
    &lt;% @a.each do |q| %&gt;
      &lt;%= link_to(q.title + ' (' + q.answer_count.to_s + ') ' + q.question_id.to_s, 'http://stackoverflow.com/' + q.question_answers_url) %&gt;  &lt;/br&gt;
  
    &lt;% end %&gt;
  }
  </code></pre>
  
  <p>Is it possible?</p>