title: Why isn't Template Toolkit aggregating my counter?
body: <p>I'm working on a simple Dancer app to log books a person has read, but in my template to show how many books a person has read, I'm stumbling into an error. I'm trying to go through ever row in the table of reading instances and add 1 to a counter if the reader is the same as the listed person.</p>
  
  <p>Here's the code for the template:</p>
  
  <pre><code>&lt;ul class="people"&gt;
  &lt;% IF people.size %&gt;
    &lt;% FOREACH id IN people.keys.nsort %&gt;
      &lt;li&gt;&lt;h2 style="display: inline;"&gt;&lt;% people.$id.name %&gt;&lt;/h2&gt;&lt;br /&gt;
      Born &lt;% people.$id.birthday %&gt;&lt;br /&gt;
      &lt;% FOREACH reader IN readings.keys.nsort %&gt;
        &lt;% count = 0 %&gt;
        &lt;% IF readings.$reader.person_id == people.$id.id %&gt;
          &lt;% count = count + 1 %&gt;
        &lt;% END %&gt;
      &lt;% END %&gt;
      &lt;% count %&gt;
    &lt;% END %&gt;
  &lt;% ELSE %&gt;
    &lt;li&gt;&lt;em&gt;Unbelievable.  No people here so far&lt;/em&gt;
  &lt;% END %&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>However, when I display it, count is only 1. Does anybody know what I'm doing wrong, or do you need more code?</p>
  
  <p>Thanks.</p>