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.
<%= 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" %>
Now, should I keep this (still view-related) logic in the view, or should I instead:
1) Write a HtmlHelper GetSupportedText(this ... extension method?
2) Write an extension method to the actual Model class?
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 <% %>.
Thanks for your input on this!
EDIT: I am also concerned about putting out HTML from a C# helper method (as string) -- that's hard to debug an really ugly.