Skip to content

Commit

Permalink
Adjust Where filter to properly handle turthy comparisons.
Browse files Browse the repository at this point in the history
  • Loading branch information
williamb1024 committed Oct 24, 2024
1 parent 30829ad commit ede8662
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Fluid/Filters/ArrayFilters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,19 @@ public static async ValueTask<FluidValue> Where(FluidValue input, FilterArgument
var member = arguments.At(0).ToStringValue();

// Second argument is the value to match, or 'true' if none is defined
var targetValue = arguments.At(1).Or(BooleanValue.True);
var targetValue = arguments.At(1);
if (targetValue.IsNil())
{
targetValue = BooleanValue.True;
}

var list = new List<FluidValue>();

foreach (var item in input.Enumerate(context))
{
var itemValue = await item.GetValueAsync(member, context);

if (itemValue.Equals(targetValue))
if (targetValue.Equals(itemValue))
{
list.Add(item);
}
Expand Down

0 comments on commit ede8662

Please sign in to comment.