Can I optimize the class assignment here at all? I have to do this in a lot of different places and am trying to figure out how to make it less…copy paste-ish / inline.
@foreach(var m in Model.ObjectList)
{
<td @if(m.RandomObject.isFlagged){
<text>class="flagged"</text>
}
>
@m.RandomObject.Name @m.RandomObject.Description
</td>
}
Note that each ObjectList in the different places has differnt RandomObjects.
I suppose this would work too, but still seems not best practice:
<td class="flagged@(m.RandomObject.isFlagged)">...
and then have the css definition be .flaggedtrue
I usually use the
?ternary operator for this kind of thing