Skip to content

Commit

Permalink
Fix all_route_data liquid attribute helper (OrchardCMS#17347)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbytes1027 authored Jan 14, 2025
1 parent 0042306 commit 4cf9052
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -54,11 +55,20 @@ public async ValueTask<Completion> WriteToAsync(IReadOnlyList<FilterArgument> 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<string, string> 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;
Expand Down

0 comments on commit 4cf9052

Please sign in to comment.