title: How to write an ASP.NET MVC Core TagHelper that would support template for collection/iteration
body: <p>I've written a bunch of HTML Helpers that cover basically all HTML elements and some HTML structures like tabs, pagers, trees etc. Now, I'd like to convert these into TagHelpers. But I couldn't find a way how to do one essential thing. </p>
  
  <p>In order to generate a table using my HTML helper, you need to write something like this:</p>
  
  <pre><code>@(Html.Table(Model.Items).Columns(columns =&gt;
  {
      columns.BoundColumn(m =&gt; m.Id).Class("id");
      columns.TemplateColumn().Class("switch")
          .Pattern((model, pattern) =&gt; pattern.Html(@&lt;span&gt;@(model.Title)&lt;/span&gt;));
      columns.BoolColumn(m =&gt; m.Default);
  
  })
  </code></pre>
  
  <p>It takes a collection as a constructor parameter and makes the items type available for the Columns property so that it's possible to bind the item properties to defined columns using lambda/anonymous functions. I have several columns that renders text/html based on its type - BoundColumn renders text, BoolColumn takes bool as a value and renders Yes/No, LinkColumn renders a link. And there's also a TemplateColumn that takes IHtmlString and this way you can pass any html structure you want to display for a particular column.</p>
  
  <p>So I was hoping that TagHelper would look something like this:</p>
  
  <pre><code>&lt;tee-table data-source="Model.Items"&gt;
    &lt;columns&gt;
      &lt;bound value="Id" /&gt;
      &lt;bool value="Default" /&gt;
      &lt;template value="SomeComplexType"&gt;
        &lt;span&gt;@value.Title&lt;/span&gt;
      &lt;/template&gt;
    &lt;/columns&gt;
  &lt;/tee-table&gt;
  </code></pre>
  
  <p>But it looks like TagHelpers don't support this at all. I found this article: <a href="http://www.dotnet-programming.com/post/2015/10/31/Building-Complex-Controls-with-AspNet-MVC-6-TagHelpers.aspx" rel="nofollow noreferrer">http://www.dotnet-programming.com/post/2015/10/31/Building-Complex-Controls-with-AspNet-MVC-6-TagHelpers.aspx</a> that is somehow close to what I'd like to do but not close enough. It still requires iteration in the view, which is something I want to avoid. Mainly because Tag Helpers are supposed to support the "HTML feel" in MVC views.</p>
  
  <p>So is there a way how to build a TagHelper that would work as a template for collection items?</p>