I did some reading and found out that you can now have local functions in razor views: https://learn.microsoft.com/en-us/aspnet/core/mvc/views/razor?view=aspnetcore-3.0#razor-code-blocks
@{
void RenderName(string name)
{
<p>Name: <strong>@name</strong></p>
}
RenderName("Mahatma Gandhi");
RenderName("Martin Luther King, Jr.");
}
And that looks great. But, for some reason this doesn't compile on my machine. Why is that? My target framework is .NetCore 3.1 and Visual Studio 2019 16.6.0. There are some error messages: "Type or namespace definition, or end-of-file expected" - on the very first line (@using statement) and then: "Invalid expression term '<'" on the line with HTML.
What is wrong with that?