title: Using IF statements in Underscore.js/Backbone.js templates
body: <p>I am receiving a JSON object where one of the value is <code>null</code>. The JSON looks like:</p>
  
  <pre><code>[{"id":"1096","price":null,
  </code></pre>
  
  <p>Right now, it is outputting a <code>NULL</code> string to the webpage with the following code. <em>(I am using the template engine in Backbone.js/Underscore.js)</em></p>
  
  <pre><code>&lt;div class="subtitle"&gt;$&lt;%= price %&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Because I want to hide the entire <code>div</code> if no <code>price</code> is returned, I added the <code>if</code> statements:</p>
  
  <pre><code>&lt;% if (price) { %&gt;
      &lt;div class="subtitle"&gt;$&lt;%= price %&gt;&lt;/div&gt;
  &lt;% } %&gt;
  </code></pre>
  
  <p>However it seems to still output the <code>div.subtitle</code>. What am I doing wrong? I also tried the following but they did not work</p>
  
  <pre><code>&lt;% if (typeof(price) != "undefined") { %&gt;
      &lt;div class="subtitle"&gt;$&lt;%= price %&gt;&lt;/div&gt;
  &lt;% } %&gt;
  
  &lt;% if (price != null) { %&gt;
      &lt;div class="subtitle"&gt;$&lt;%= price %&gt;&lt;/div&gt;
  &lt;% } %&gt;
  
  &lt;% if (price != "null") { %&gt;
      &lt;div class="subtitle"&gt;$&lt;%= price %&gt;&lt;/div&gt;
  &lt;% } %&gt;
  </code></pre>
  
  <p><strong>I suspect this has to do with using <code>if</code> statements inside Underscore.js's templates</strong></p>