@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 { } } }
@Safe.Raw(key) @if (IsValidURL(str)) { @Safe.Raw(str) } else { @Safe.Raw(value?.ToString()) } @Safe.Raw(key) @if (IsValidURL(str2)) { @Safe.Raw(str2) } else { @Safe.Raw(subItems.First().Value?.ToString()) } @Safe.Raw($"{key}")