mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-15 08:50:45 -07:00
Bring back silencing of errors in blank nodes for backwards compatibility (#1292)
This commit is contained in:
@@ -77,7 +77,10 @@ module Liquid
|
|||||||
raise
|
raise
|
||||||
rescue ::StandardError => e
|
rescue ::StandardError => e
|
||||||
line_number = node.is_a?(String) ? nil : node.line_number
|
line_number = node.is_a?(String) ? nil : node.line_number
|
||||||
output << context.handle_error(e, line_number)
|
error_message = context.handle_error(e, line_number)
|
||||||
|
if node.instance_of?(Variable) || !node.blank? # conditional for backwards compatibility
|
||||||
|
output << error_message
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private def parse_liquid_tag(markup, parse_context)
|
private def parse_liquid_tag(markup, parse_context)
|
||||||
|
|||||||
@@ -261,4 +261,12 @@ class ErrorHandlingTest < Minitest::Test
|
|||||||
assert_equal("Argument error:\nLiquid error (product line 1): argument error", page)
|
assert_equal("Argument error:\nLiquid error (product line 1): argument error", page)
|
||||||
assert_equal("product", template.errors.first.template_name)
|
assert_equal("product", template.errors.first.template_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_bug_compatible_silencing_of_errors_in_blank_nodes
|
||||||
|
output = Liquid::Template.parse("{% assign x = 0 %}{% if 1 < '2' %}not blank{% assign x = 3 %}{% endif %}{{ x }}").render
|
||||||
|
assert_equal("Liquid error: comparison of Integer with String failed0", output)
|
||||||
|
|
||||||
|
output = Liquid::Template.parse("{% assign x = 0 %}{% if 1 < '2' %}{% assign x = 3 %}{% endif %}{{ x }}").render
|
||||||
|
assert_equal("0", output)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user