Render fragments can be defined using Razor template syntax. The templated components can be rendered either using a Razor template with an argument or directly.
@page "/razor"
@{
RenderFragment template = @<p>The time is @DateTime.Now.</p>;
RenderFragment<Employee> ItemTemplate = (item) => @<p>Employee name is @item.Name.</p>;
}
@template
@ItemTemplate(emp)
@code {
Employee emp = new Employee { Name = "Test" };
public class Employee
{
public string Name;
}
}
Reference link:
https://docs.microsoft.com/en-us/aspnet/core/blazor/components?view=aspnetcore-3.0#razor-templates
Share with