Do not raise property error

This commit is contained in:
Ian Ker-Seymer
2025-04-02 22:18:09 -04:00
parent a7ad5f4282
commit 7900043ffc
2 changed files with 11 additions and 17 deletions
+1 -5
View File
@@ -992,11 +992,7 @@ module Liquid
ary = InputIterator.new(input, context) ary = InputIterator.new(input, context)
return default_value if ary.empty? return default_value if ary.empty?
if property.nil? property = Utils.to_s(property)
raise_property_error(property)
end
property = Liquid::Utils.to_s(property)
block.call(ary) do |item| block.call(ary) do |item|
if target_value.nil? if target_value.nil?
+10 -12
View File
@@ -1033,22 +1033,20 @@ class StandardFiltersTest < Minitest::Test
assert_template_result(expected_output, template, { "array" => array }) assert_template_result(expected_output, template, { "array" => array })
end end
def test_where_with_empty_string_and_nil def test_where_with_empty_string_is_a_no_op
array = [ environment = { "array" => ["alpha", "beta", "gamma"] }
"alpha",
"beta",
"gamma",
]
template = "{{ array | where: '' | join: ' ' }}"
expected_output = "alpha beta gamma" expected_output = "alpha beta gamma"
assert_template_result(expected_output, template, { "array" => array }) template = "{{ array | where: '' | join: ' ' }}"
assert_template_result(expected_output, template, environment)
end
def test_where_with_nil_is_a_no_op
environment = { "array" => ["alpha", "beta", "gamma"] }
expected_output = "alpha beta gamma"
template = "{{ array | where: nil | join: ' ' }}" template = "{{ array | where: nil | join: ' ' }}"
exception = assert_raises(Liquid::ArgumentError) do
assert_template_result(expected_output, template, { "array" => array })
end
assert_equal("Liquid error (line 1): cannot select the property ''", exception.message) assert_template_result(expected_output, template, environment)
end end
def test_where_with_value def test_where_with_value