mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Bring back silencing of errors in blank nodes for backwards compatibility (#1292)
This commit is contained in:
committed by
GitHub
parent
fb77921b15
commit
77084930e9
@@ -77,7 +77,10 @@ module Liquid
|
||||
raise
|
||||
rescue ::StandardError => e
|
||||
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
|
||||
|
||||
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("product", template.errors.first.template_name)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user