Here is a way that we are currently spitting out some HTML to our view.
foreach (var reportGroup in managedReportGroup.CustomerTags)
{ %>
<%= reportGroup.Name %>
<%
}
Is there something that I can do like this? (This won’t work for me)
Action<ManagedReportGroups> handlesReportGroup = delegate(ManagedReportGroups managedReportGroup)
{
foreach (var reportGroup in managedReportGroup.CustomerTags)
{
Html.Encode(reportGroup.Name);
}
};
The reason would be to cut down on the aligator brackets and clean up my code.
Thanks,
Mike
If you move it to partial views, you will still have to do the loop inside the partial.
You could create custom Html extension methods if you were really dead-set against your first example.
Or if your main goal really is to reduce “alligator brackets” you could cut it down to two if you did it this way:
You might also consider the Spark View Engine