title: count items jquery template
body: <p>How do i count the items in a each jquery template and the apply a if to that variable</p>
  
  <p>something like</p>
  
  <pre><code>&lt;script id="inventorySummaryTmpl" type="text/x-jquery-tmpl"&gt; 
  &lt;tr&gt;
  {{each response}}
      {{if response.length === 2 }}
          &lt;/tr&gt;&lt;tr&gt;
      {{/if}}
          &lt;td&gt;&lt;img src='${icon}'&gt; ${title} &lt;/td&gt;
  {{/each}}
  
  &lt;/tr&gt;
  </code></pre>
  
  <p></p>
  
  <p>This is the javascript that loads the JSON and interacts with the jquery.TMPL</p>
  
  <pre><code> var ip = window.location.hash;
  
  
      var request = $.ajax({
          type: 'GET',
          url: 'ajax/dashboard/widgets/inventorySummary.xsp?ip='+ip.substring(1),
          dataType: 'json'
      });
  
      request.done(function(data){
          $("#inventorySummaryTmpl").tmpl(data).appendTo("#inventorySummaryContent");
      });
  
      request.fail(function(jqXHR, textStatus, errorThrown) {
          console.log(errorThrown);
          console.log(textStatus)
      });
  </code></pre>
  
  <p>And the JSON </p>
  
  <pre><code>{
  
  "response": [
      {
          "icon": "workstation",
          "nbItems": "38",
          "title": "Workstations"
      },
      {
          "icon": "server",
          "nbItems": "2",
          "title": "Servers"
      }
  ]
  </code></pre>
  
  <p>}</p>
  
  <p>if someone has any ideeas.</p>