mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-20 19:30:47 -07:00
Always return boolean in has filter
This commit is contained in:
@@ -460,7 +460,7 @@ module Liquid
|
|||||||
# @liquid_syntax array | has: string, string
|
# @liquid_syntax array | has: string, string
|
||||||
# @liquid_return [boolean]
|
# @liquid_return [boolean]
|
||||||
def has(input, property, target_value = nil)
|
def has(input, property, target_value = nil)
|
||||||
filter_array(input, property, target_value, false) { |ary, &block| ary.any?(&block) }
|
filter_array(input, property, target_value, false) { |ary, &block| ary.any?(&block) } || false
|
||||||
end
|
end
|
||||||
|
|
||||||
# @liquid_public_docs
|
# @liquid_public_docs
|
||||||
|
|||||||
@@ -2,5 +2,5 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Liquid
|
module Liquid
|
||||||
VERSION = "5.8.3"
|
VERSION = "5.8.4"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -977,6 +977,12 @@ class StandardFiltersTest < Minitest::Test
|
|||||||
assert_template_result(expected_output, template, { "array" => array })
|
assert_template_result(expected_output, template, { "array" => array })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_has_with_boolean_input
|
||||||
|
template = "Result: {{a0 | has: a1, a2}}"
|
||||||
|
|
||||||
|
assert_template_result("Result: false", template, { "a0" => false })
|
||||||
|
end
|
||||||
|
|
||||||
def test_has_with_false_value_when_does_not_have_it
|
def test_has_with_false_value_when_does_not_have_it
|
||||||
array = [
|
array = [
|
||||||
{ "handle" => "alpha", "ok" => true },
|
{ "handle" => "alpha", "ok" => true },
|
||||||
|
|||||||
Reference in New Issue
Block a user