@model (Dictionary Items, int Level) @functions { private bool IsValidURL(string source) { return Uri.TryCreate(source, UriKind.Absolute, out var uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps); } } @if (Model.Items.Count > 0) { @foreach (var (key, value) in Model.Items) { @if (value is string str) { if (!string.IsNullOrEmpty(key)) { } } else if (value is Dictionary {Count: > 0 } subItems) { } else if (value is IEnumerable valueArray) { } }
@key @if (IsValidURL(str)) { @str } else { @value?.ToString() } @{ @if (!string.IsNullOrEmpty(key)) { Write(Html.Raw($"")); Write(key); Write(Html.Raw($"")); } } @{ @if (!string.IsNullOrEmpty(key)) { Write(Html.Raw($"")); Write(key); Write(Html.Raw($"")); } } @foreach (var item in valueArray) { @if (item is Dictionary {Count: > 0 } subItems2) { } else { } }
}