title: How to use if statements in underscore.js templates?
body: <p>I'm using the underscore.js templating function and have done a template like this: </p>
  
  <pre><code>&lt;script type="text/template" id="gridItem"&gt;
      &lt;div class="griditem &lt;%= gridType %&gt; &lt;%= gridSize %&gt;"&gt;
          &lt;img src="&lt;%= image %&gt;" /&gt;
          &lt;div class="content"&gt;
              &lt;span class="subheading"&gt;&lt;%= categoryName %&gt;&lt;/span&gt;
              &lt;% if (date) { %&gt;&lt;span class="date"&gt;&lt;%= date %&gt;&lt;/span&gt;&lt;% }  %&gt;
              &lt;h2&gt;&lt;%= title %&gt;&lt;/h2&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>As you can see I have an if statement in there because all of my models won't have the date parameter. However this way of doing it gives me an error <code>date is not defined</code>. So, how can I do if statements within a template?</p>