diff --git a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Tags/AnchorTag.cs b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Tags/AnchorTag.cs index 49c21253929..c8b5bdbcd34 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Tags/AnchorTag.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Tags/AnchorTag.cs @@ -1,6 +1,7 @@ using System.Text.Encodings.Web; using Fluid; using Fluid.Ast; +using Fluid.Values; using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewFeatures; using Microsoft.AspNetCore.Routing; @@ -54,11 +55,20 @@ public async ValueTask WriteToAsync(IReadOnlyList ar case "all_route_data": - var allRouteData = (await argument.Expression.EvaluateAsync(context)).ToObjectValue(); + var objectValue = (await argument.Expression.EvaluateAsync(context)).ToObjectValue(); - if (allRouteData is Dictionary allRouteValues) + if (objectValue is IFluidIndexable allRouteData) { - routeValues = allRouteValues; + // Copy all string key-value pairs to routeValues + routeValues = new(); + foreach (var key in allRouteData.Keys) + { + bool success = allRouteData.TryGetValue(key, out FluidValue fluidValue); + if (success && fluidValue is StringValue) + { + routeValues.Add(key, fluidValue.ToStringValue()); + } + } } break;