title: ASP.NET MVC: How much processing in the view & when to use helper methods?
body: <p>My ASP.NET MVC view is getting "cluttered up" because often times I need to conditionally show things which leads to long inline C# code, including hard to read ternary operator statements such as below (demo purposes only) and similar constructs.</p>
  
  <p><code></p>
  
  <pre><code>&lt;%= Model.SupportsFeature ? Model.HasName ? "This model supports the feature and has a name" : "This model supports the feature and has no name" : "This model doesn't support the feature" %&gt;
  </code></pre>
  
  <p></code></p>
  
  <p>Now, should I keep this (still view-related) logic in the view, or should I instead:</p>
  
  <p>1) Write a HtmlHelper GetSupportedText(this ...   extension method?</p>
  
  <p>2) Write an extension method to the actual Model class?</p>
  
  <p>I'm trying to keep my code concise and keep related things together, but I'm really not sure how to structure this and deal with views that become cluttered with &lt;% %>.</p>
  
  <p>Thanks for your input on this!</p>
  
  <p><strong>EDIT</strong>:
  I am also concerned about putting out HTML from a C# helper method (as string) -- that's hard to debug an really ugly.</p>