title: Recursion in ASP.NET Core Razor views
body: <p>I have the following code right now to write a flat list of items with a link to a controller action:</p>
  
  <pre><code>&lt;ul&gt;
      @foreach (var item in items)
      {
          &lt;li&gt;
              &lt;a asp-controller="Home" asp-action="Demo" asp-route-itemName="@item.Name"&gt;
                  @item.Name
              &lt;/a&gt;
          &lt;/li&gt;
      }
  &lt;/ul&gt;
  </code></pre>
  
  <p>Now this must become recursive. Items can also contain subitems. For recursion I need some sort of function. I know I could use <code>@functions</code> and define the function in the .cshtml file. Not sure whether such nice inline HTML code with tag helpers would still be allowed there, it didn't seem so. Another option is HTML helpers in a .cs file, no inline HTML here for sure. <code>@helper</code> doesn't seem to be available anymore.</p>
  
  <p>What other options do I have to define a function and keep the inline HTML syntax that Razor offers?</p>