From .NET 5 Preview 7, Blazor components trim insignificant whitespaces to achieve better performance. This has been implemented as a result of the finding that 40% of the rendering time is consumed by whitespace nodes. If whitespace node removal causes unexpected behavior, you can simply enable it by using the @preservewhitespace directive.
@using System.Linq
@preservewhitespace true
<ul>
@foreach (var item in forecasts)
{
<li>
Temperature: @item.TemperatureC
</li>
}
</ul>
@code {
private WeatherForecast[] forecasts;
protected override void OnInitialized()
{
forecasts = Enumerable.Range(1, 10).Select(x => new WeatherForecast()
{
TemperatureC = x
}).ToArray();
}
public class WeatherForecast
{
public int TemperatureC { get; set; }
}
}
From .NET 5 Preview 7, Blazor components trim insignificant whitespaces to achieve better performance. This has been implemented as a result of the finding that 40% of the rendering time is consumed by whitespace nodes. If whitespace node removal causes unexpected behavior, you can simply enable it by using the @preservewhitespace directive.
need an explanation for this answer? contact us directly to get an explanation for this answer