You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the where filter with a single argument, the filter does not perform truthy comparisons. The equality comparison is performed with the property value controlling.
internalstaticclassWhereFilter{internalconststringName="twhere";// Track issue: https://github.com/sebastienros/fluid/issues/620internalstaticasyncValueTask<FluidValue>Where(FluidValueinput,FilterArgumentsarguments,TemplateContextcontext){if(input.Type != FluidValues.Array){returninput;}// First argument is the property name to matchvarmember= arguments.At(0).ToStringValue();// Second argument is the value to match, or 'true' if none is definedvartargetValue= arguments.At(1).Or(BooleanValue.True);varlist=newList<FluidValue>();foreach(var item in input.Enumerate(context)){varitemValue=await item.GetValueAsync(member, context);if(itemValue.Equals(targetValue)||// Issue workaround for equality inconsistencies: to check if the other equals self
targetValue.Equals(itemValue)){
list.Add(item);}}returnnew ArrayValue(list);}}
So instead of comparing to true we actually need to handle the single argument separately and convert it using ToBooleanValue(). Can someone create a PR and a test for that?
When using the
where
filter with a single argument, the filter does not perform truthy comparisons. The equality comparison is performed with the property value controlling.fluid/Fluid/Filters/ArrayFilters.cs
Line 156 in 74cb742
Switching
itemValue
andtargetValue
, such thattargetValue
is controlling would result in truthy comparisons.The text was updated successfully, but these errors were encountered: