title: Custom Html helpers generate html via a view .cshtml file
body: <p>I am trying to create my own Html helper that will allow me to reuse some functionality across any web application. If I wanted to reuse this control in a single wep app I could create a .cshtml file and call it via the Html.Partial("") method and pass in a Model.</p>
  
  <p>However as I have a class library project for my custom Html helpers I am creating the html with a string builder like this simplified version</p>
  
  <pre><code>StringBuilder htmlBuilder = new StringBuilder("&lt;div class='myClass'&gt;")
  
  foreach(var item in MyItems)
  {
    htmlBuilder.Append($"item : {item.Name}");
  }
  
  htmlBuilder.append("&lt;/div&gt;");
  </code></pre>
  
  <p>This makes it a pain to maintain especially as my control gets more features.</p>
  
  <p>Is there a recommended way to leverage the razor engine where I can write the html in a .cshtml file with a model and then generate the html instead of using a string builder?</p>