-
Notifications
You must be signed in to change notification settings - Fork 229
Open
Milestone
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.
@if (Item.ChildItems.Any())
{
@if (!string.IsNullOrEmpty(Item.Role))
{
<AuthorizeView Roles="@Item.Role">
<Authorized>
@NavGroupTemplate
</Authorized>
</AuthorizeView>
}
else
{
@NavGroupTemplate
}
}
else
{
<a href="@Item.Href" class="nav-link">@Item.Text</a>
}
@code {
[Parameter, EditorRequired]
public NavItem Item { get; set; }
private bool _isExpanded;
private RenderFragment NavGroupTemplate => __builder =>
{
<a href="@Item.Href" class="nav-link" @onclick="() => _isExpanded = !_isExpanded">@Item.Text</a>
@if (_isExpanded)
{
@foreach (var item in Item.ChildItems)
{
<NavMenuItem Item="item" />
}
}
};
}public class NavItem
{
/// <summary>
/// Gets or sets the HyperText Reference (href).
/// </summary>
public string? Href { get; set; }
/// <summary>
/// Gets or sets the navigation link text.
/// </summary>
public string? Text { get; set; }
/// <summary>
/// Gets or sets the required authorization role to view this navigation item.
/// </summary>
public string? Role { get; set; }
/// <summary>
/// Gets or sets the collection of child navigation items.
/// </summary>
public IEnumerable<NavItem> ChildItems { get; set; } = [];
}Metadata
Metadata
Assignees
Labels
No labels