I'm working on a Blazor component with a table where it makes sense to factor out a couple pieces of the template. However it's not rendering correctly and the td elements I'm producing are not ending up inside the tr element, but instead are at the same level.
Below is a simplified version of the code. The body has the problem while the footer renders correctly. What is the correct way to accomplish what I'm trying to here? I know I could avoid all of the Razor syntax and just create a function that returns a raw MarkupString, but that doesn't seem like it should be necessary for a case like this.
<table>
<tbody>
@foreach (var row in data)
{
@:<tr>
RenderRow(row);
@:</tr>
}
</tbody>
<tfoot>
<tr>
@if (footerRow != null)
{
RenderRow(footerRow);
}
</tr>
</tfoot>
</table>
@{
void RenderRow(Row row)
{
<td>@row.RowNum</td>
RenderRowHalf(row.Left);
RenderRowHalf(row.Right);
}
void RenderRowHalf(RowHalf half)
{
<td>@half.Foo</td>
<td>@(Util.ColorNumber(half.Bar))</td>
}
}