@model (string Key, object Value, 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.Value is string str) { if (!string.IsNullOrEmpty(Model.Key)) { @Model.Key } @* Explicitely remove whitespace at front here *@@if (IsValidURL(str)){@str}else {@str.Trim()} } else if (Model.Value is Dictionary { Count: > 0 } subItems) { @{ @if (!string.IsNullOrEmpty(Model.Key)) { Write(Html.Raw($"")); Write(Model.Key); Write(Html.Raw($"")); } } } else if (Model.Value is IEnumerable valueArray) { @{ @if (!string.IsNullOrEmpty(Model.Key)) { Write(Html.Raw($"")); Write(Model.Key); Write(Html.Raw($"")); } } @foreach (var item in valueArray) { @if (item is Dictionary { Count: > 0 } subItems2) { } else { } } }