In a Blazor component, when there is some html that repeats but it's not complex enough to justify the creation of one extra component, I put this html into a RenderFragmet private field or function, so I can reuse it along the component. A simplified example:
<ul> @menuOption("Menu 1") @menuOption("Menu 2") @menuOption("Menu 3")</ul>@code { private RenderFragment menuOption(string title) => @<li class="text-lg font-bold bg-blue-500 px-4 py-2">@title</li>;}But I don't know how to write the RenderFragment literal if there is no 'root element' for the RenderFragment. For example, in React I can do:
const fragment = <><div>1</div><div>2</div><div>3</div></>;but in Blazor I can't do:
private RenderFragment fragment = @<><div>1</div><div>2</div><div>3</div></>;Is there something similar in Blazor?
Regards.