Wrong syntax highlighting in RenderFragments
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
@davidwengier another issue with syntax highlighting in the razor editor. This time within custom renderfragments which I want to re-use in different places. Notice how `@Item.Href` and `@onclick="() => _isExpanded = !_isExpanded"` are displayed in brown.
```razor
@if (Item.ChildItems.Any())
{
@if (!string.IsNullOrEmpty(Item.Role))
{
@NavGroupTemplate
}
else
{
@NavGroupTemplate
}
}
else
{
@Item.Text
}
@code {
[Parameter, EditorRequired]
public NavItem Item { get; set; }
private bool _isExpanded;
private RenderFragment NavGroupTemplate => __builder =>
{
@Item.Text
@if (_isExpanded)
{
@foreach (var item in Item.ChildItems)
{
}
}
};
}
```
```cs
public class NavItem
{
///
/// Gets or sets the HyperText Reference (href).
///
public string? Href { get; set; }
///
/// Gets or sets the navigation link text.
///
public string? Text { get; set; }
///
/// Gets or sets the required authorization role to view this navigation item.
///
public string? Role { get; set; }
///
/// Gets or sets the collection of child navigation items.
///
public IEnumerable ChildItems { get; set; } = [];
}
```
Contributor guide
Assessment
This issue has not been assessed yet.