@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); } } @foreach (var (key, value) in Model.Items) { @if (value is string str) { if (!string.IsNullOrEmpty(key)) { } } else if (value is DictionarysubItems) { @* This is the array case *@ if (subItems.Count == 1 && subItems.First().Value is string str2) { } else { } } }
@key @if (IsValidURL(str)) { @str } else { @value?.ToString() } @key @if (IsValidURL(str2)) { @str2 } else { @subItems.First().Value?.ToString() } @{ Write(Html.Raw($"")); Write(key); Write(Html.Raw($"")); }