title: C# if statement within Javascript, Razor/MVC3
body: <p>Ok, so I'm trying to use an "if" statement within my javascript. Depending on a boolean in my model, a function should return some html or an empty string. This is basically what I want to do:</p>
  
  <pre><code>function getSomeHtml() {
  var myHtml = '';
  @if(Model.UseSomeNiceHtml)
  {
  &lt;text&gt; 
  myHtml += '&lt;div&gt; &lt;p class="label"&gt;Whatever&lt;/p&gt;&lt;/div&gt;'; 
  &lt;/text&gt;
  }
  return myHtml;
  }
  </code></pre>
  
  <p>Similar code works really well when using a foreach loop (basically replacing if with foreach in the example above). With the if statement I get the error <strong>"Encountered end tag "text" with no matching start tag.  Are your start/end tags properly balanced?"</strong>. When I remove the <code>&lt;text&gt;</code> tags I get the error <strong>"Too many characters in character literal"</strong>.</p>
  
  <p>Could anyone point me in the right direction?</p>
  
  <p>Thank you! :)</p>