title: Razor View Engine: Complex looping and HTML
body: <p>I have lots of complex HTML reports in my current project where there we perform lots of conditional rendering of TRs and TDs with rowspans and colspans.</p>
  
  <p>It could sometimes look like this (this is extremely simplified):</p>
  
  <pre><code>&lt;tr&gt;
  @foreach (var ourItem in ourList) {
     if (ourItem != ourList.First()) {
        &lt;tr&gt;                
     }
     &lt;td&gt;&lt;/td&gt;
     &lt;/tr&gt;
  }
  </code></pre>
  
  <p>However, Razor claims: "The foreach loop is missing a closing "}" character". (within Visual Studio)</p>
  
  <p>I've tried to wrap the <code>&lt;tr&gt;</code> in <code>&lt;text&gt;&lt;/text&gt;</code> which makes the closing } problem go away only to find this when run: "Encountered end tag "tr" with no matching start tag. Are your start/end tags properly balanced".</p>
  
  <p>How would I do this kind of conditional rendering while convincing Razor not to bother about the HTML at all, cause the HTML is balanced when all the looping is done. Or at least that was the case when the ASP.NET View Engine was used.</p>