Allow multiple binary operator in where_exp filter (#8047)

Merge pull request 8047
This commit is contained in:
Ashwin Maroli
2020-03-06 21:38:56 +05:30
committed by GitHub
parent ab6ef0b257
commit 0f4c8d2248
2 changed files with 24 additions and 3 deletions

View File

@@ -997,6 +997,23 @@ class TestFilters < JekyllUnitTest
)
end
should "filter objects across multiple conditions" do
sample = [
{ "color" => "teal", "size" => "large", "type" => "variable" },
{ "color" => "red", "size" => "large", "type" => "fixed" },
{ "color" => "red", "size" => "medium", "type" => "variable" },
{ "color" => "blue", "size" => "medium", "type" => "fixed" },
]
assert_equal(
[
{ "color" => "red", "size" => "large", "type" => "fixed" },
],
@filter.where_exp(
sample, "item", "item.type == 'fixed' and item.color == 'red' or item.color == 'teal'"
)
)
end
should "stringify during comparison for compatibility with liquid parsing" do
hash = {
"The Words" => { "rating" => 1.2, "featured" => false },