title: Getting HTML headings to be dynamically output by Razor
body: <p>I am creating a page in Razor and I am trying to dynamically output headings depending on how deep the node is.</p>
  
  <p>So the top level node is a h1, second level h2 etc...</p>
  
  <p>The bit I am struggling is getting razor to dynamically output the headings. Half of it seems to be working but the closing tag will not output.</p>
  
  <p>This is the razor:</p>
  
  <pre><code>&lt;h@{@parts} id="#@item.Id"&gt;@sectionString@level @item.Name &lt;/h@{@parts} &gt;
  </code></pre>
  
  <p>Which outputs the following HTML:</p>
  
  <pre><code>&lt;h4 id="#1073"&gt;4.1.1 Get a baseline &lt;/h@{@parts} &gt;
  </code></pre>
  
  <p>If I remove the forward slash it works, but then i end up with <code>&lt;h3&gt;&lt;h3&gt;</code> rather than <code>&lt;h3&gt;&lt;/h3&gt;</code>.</p>
  
  <p>I have also tried:</p>
  
  <pre><code>&lt;h@{@parts} id="#@item.Id"&gt;@sectionString@level @item.Name &lt;/h@parts &gt;
  
  &lt;h@{@parts} id="#@item.Id"&gt;@sectionString@level @item.Name &lt;/h@{parts} &gt;
  </code></pre>
  
  <p>If I can't get this to work I guess I will have to resort to a very long if statement which I would rather avoid. I think the slash needs escaping somehow? Thank-you.</p>