Bump Liquid to 5.11.0 (#2012)

This commit reverts the Inline Snippets tag (#2001) and bumps
Liquid to 5.11. For now, the inclusion of Inline Snippets
in the latest Liquid release is being treated as a bug.

While #2001 does implement the scope contained in RFC#1916,
we need to take a step back to make sure we’re setting our
sights high enough with this feature, and that we’re truly
supporting theme developers in the ways they need.

If you have any feedback, please leave a comment on RFC#1916.

- Liquid Developer Tools
This commit is contained in:
Guilherme Carreiro
2025-11-19 18:03:23 +01:00
committed by GitHub
parent cbd8a0a2ee
commit 32b50ecafe
33 changed files with 163 additions and 1326 deletions
+4 -4
View File
@@ -101,7 +101,7 @@ class CycleTagTest < Minitest::Test
assert_template_result("a", template2)
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
error1 = assert_raises(Liquid::SyntaxError) { Template.parse(template1) }
error2 = assert_raises(Liquid::SyntaxError) { Template.parse(template2) }
@@ -129,7 +129,7 @@ class CycleTagTest < Minitest::Test
assert_template_result("N", template5)
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
error1 = assert_raises(Liquid::SyntaxError) { Template.parse(template1) }
error2 = assert_raises(Liquid::SyntaxError) { Template.parse(template2) }
error3 = assert_raises(Liquid::SyntaxError) { Template.parse(template3) }
@@ -157,7 +157,7 @@ class CycleTagTest < Minitest::Test
refute_nil(Template.parse(template))
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
error = assert_raises(Liquid::SyntaxError) { Template.parse(template) }
assert_match(/Unexpected character =/, error.message)
end
@@ -174,7 +174,7 @@ class CycleTagTest < Minitest::Test
refute_nil(Template.parse(template))
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
error = assert_raises(Liquid::SyntaxError) { Template.parse(template) }
assert_match(/Unexpected character =/, error.message)
end
+5 -5
View File
@@ -204,7 +204,7 @@ class IncludeTagTest < Minitest::Test
)
end
def test_rigid_parsing_errors
def test_strict2_parsing_errors
with_error_modes(:lax, :strict) do
assert_template_result(
'hello value1 value2',
@@ -213,7 +213,7 @@ class IncludeTagTest < Minitest::Test
)
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
assert_syntax_error(
'{% include "snippet" !!! arg1: "value1" ~~~ arg2: "value2" %}',
)
@@ -408,7 +408,7 @@ class IncludeTagTest < Minitest::Test
refute_nil(Template.parse(template))
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
error = assert_raises(Liquid::SyntaxError) { Template.parse(template) }
assert_match(/Unexpected character =/, error.message)
end
@@ -421,7 +421,7 @@ class IncludeTagTest < Minitest::Test
refute_nil(Template.parse(template))
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
error = assert_raises(Liquid::SyntaxError) { Template.parse(template) }
assert_match(/Unexpected character =/, error.message)
end
@@ -434,7 +434,7 @@ class IncludeTagTest < Minitest::Test
refute_nil(Template.parse(template))
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
error = assert_raises(Liquid::SyntaxError) { Template.parse(template) }
assert_match(/Unexpected character =/, error.message)
end
+8 -11
View File
@@ -101,7 +101,11 @@ class RenderTagTest < Minitest::Test
end
end
def test_rigid_parsing_errors
def test_dynamically_choosen_templates_are_not_allowed
assert_syntax_error("{% assign name = 'snippet' %}{% render name %}")
end
def test_strict2_parsing_errors
with_error_modes(:lax, :strict) do
assert_template_result(
'hello value1 value2',
@@ -110,7 +114,7 @@ class RenderTagTest < Minitest::Test
)
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
assert_syntax_error(
'{% render "snippet" !!! arg1: "value1" ~~~ arg2: "value2" %}',
)
@@ -290,13 +294,6 @@ class RenderTagTest < Minitest::Test
)
end
def test_render_tag_with_snippet_drop
assert_template_result(
"Hello from snippet",
"{% snippet my_snippet %}Hello from snippet{% endsnippet %}{% render my_snippet %}",
)
end
def test_render_tag_renders_error_with_template_name
assert_template_result(
'Liquid error (foo line 1): standard error',
@@ -325,7 +322,7 @@ class RenderTagTest < Minitest::Test
refute_nil(Template.parse(template))
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
error = assert_raises(Liquid::SyntaxError) { Template.parse(template) }
assert_match(/Unexpected character =/, error.message)
end
@@ -338,7 +335,7 @@ class RenderTagTest < Minitest::Test
refute_nil(Template.parse(template))
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
error = assert_raises(Liquid::SyntaxError) { Template.parse(template) }
assert_match(/Unexpected character =/, error.message)
end
File diff suppressed because it is too large Load Diff
+28 -28
View File
@@ -259,7 +259,7 @@ class TableRowTest < Minitest::Test
)
end
def test_tablerow_with_cols_attribute_in_rigid_mode
def test_tablerow_with_cols_attribute_in_strict2_mode
template = <<~LIQUID.chomp
{% tablerow i in (1..6) cols: 3 %}{{ i }}{% endtablerow %}
LIQUID
@@ -270,12 +270,12 @@ class TableRowTest < Minitest::Test
<tr class="row2"><td class="col1">4</td><td class="col2">5</td><td class="col3">6</td></tr>
OUTPUT
with_error_modes(:rigid) do
with_error_modes(:strict2) do
assert_template_result(expected, template)
end
end
def test_tablerow_with_limit_attribute_in_rigid_mode
def test_tablerow_with_limit_attribute_in_strict2_mode
template = <<~LIQUID.chomp
{% tablerow i in (1..10) limit: 3 %}{{ i }}{% endtablerow %}
LIQUID
@@ -285,12 +285,12 @@ class TableRowTest < Minitest::Test
<td class="col1">1</td><td class="col2">2</td><td class="col3">3</td></tr>
OUTPUT
with_error_modes(:rigid) do
with_error_modes(:strict2) do
assert_template_result(expected, template)
end
end
def test_tablerow_with_offset_attribute_in_rigid_mode
def test_tablerow_with_offset_attribute_in_strict2_mode
template = <<~LIQUID.chomp
{% tablerow i in (1..5) offset: 2 %}{{ i }}{% endtablerow %}
LIQUID
@@ -300,12 +300,12 @@ class TableRowTest < Minitest::Test
<td class="col1">3</td><td class="col2">4</td><td class="col3">5</td></tr>
OUTPUT
with_error_modes(:rigid) do
with_error_modes(:strict2) do
assert_template_result(expected, template)
end
end
def test_tablerow_with_range_attribute_in_rigid_mode
def test_tablerow_with_range_attribute_in_strict2_mode
template = <<~LIQUID.chomp
{% tablerow i in (1..3) range: (1..10) %}{{ i }}{% endtablerow %}
LIQUID
@@ -315,12 +315,12 @@ class TableRowTest < Minitest::Test
<td class="col1">1</td><td class="col2">2</td><td class="col3">3</td></tr>
OUTPUT
with_error_modes(:rigid) do
with_error_modes(:strict2) do
assert_template_result(expected, template)
end
end
def test_tablerow_with_multiple_attributes_in_rigid_mode
def test_tablerow_with_multiple_attributes_in_strict2_mode
template = <<~LIQUID.chomp
{% tablerow i in (1..10) cols: 2, limit: 4, offset: 1 %}{{ i }}{% endtablerow %}
LIQUID
@@ -331,12 +331,12 @@ class TableRowTest < Minitest::Test
<tr class="row2"><td class="col1">4</td><td class="col2">5</td></tr>
OUTPUT
with_error_modes(:rigid) do
with_error_modes(:strict2) do
assert_template_result(expected, template)
end
end
def test_tablerow_with_variable_collection_in_rigid_mode
def test_tablerow_with_variable_collection_in_strict2_mode
template = <<~LIQUID.chomp
{% tablerow n in numbers cols: 2 %}{{ n }}{% endtablerow %}
LIQUID
@@ -347,12 +347,12 @@ class TableRowTest < Minitest::Test
<tr class="row2"><td class="col1">3</td><td class="col2">4</td></tr>
OUTPUT
with_error_modes(:rigid) do
with_error_modes(:strict2) do
assert_template_result(expected, template, { 'numbers' => [1, 2, 3, 4] })
end
end
def test_tablerow_with_dotted_access_in_rigid_mode
def test_tablerow_with_dotted_access_in_strict2_mode
template = <<~LIQUID.chomp
{% tablerow n in obj.numbers cols: 2 %}{{ n }}{% endtablerow %}
LIQUID
@@ -363,12 +363,12 @@ class TableRowTest < Minitest::Test
<tr class="row2"><td class="col1">3</td><td class="col2">4</td></tr>
OUTPUT
with_error_modes(:rigid) do
with_error_modes(:strict2) do
assert_template_result(expected, template, { 'obj' => { 'numbers' => [1, 2, 3, 4] } })
end
end
def test_tablerow_with_bracketed_access_in_rigid_mode
def test_tablerow_with_bracketed_access_in_strict2_mode
template = <<~LIQUID.chomp
{% tablerow n in obj["numbers"] cols: 2 %}{{ n }}{% endtablerow %}
LIQUID
@@ -378,12 +378,12 @@ class TableRowTest < Minitest::Test
<td class="col1">10</td><td class="col2">20</td></tr>
OUTPUT
with_error_modes(:rigid) do
with_error_modes(:strict2) do
assert_template_result(expected, template, { 'obj' => { 'numbers' => [10, 20] } })
end
end
def test_tablerow_without_attributes_in_rigid_mode
def test_tablerow_without_attributes_in_strict2_mode
template = <<~LIQUID.chomp
{% tablerow i in (1..3) %}{{ i }}{% endtablerow %}
LIQUID
@@ -393,30 +393,30 @@ class TableRowTest < Minitest::Test
<td class="col1">1</td><td class="col2">2</td><td class="col3">3</td></tr>
OUTPUT
with_error_modes(:rigid) do
with_error_modes(:strict2) do
assert_template_result(expected, template)
end
end
def test_tablerow_without_in_keyword_in_rigid_mode
def test_tablerow_without_in_keyword_in_strict2_mode
template = '{% tablerow i (1..10) %}{{ i }}{% endtablerow %}'
with_error_modes(:rigid) do
with_error_modes(:strict2) do
error = assert_raises(SyntaxError) { Template.parse(template) }
assert_equal("Liquid syntax error: For loops require an 'in' clause in \"i (1..10)\"", error.message)
end
end
def test_tablerow_with_multiple_invalid_attributes_reports_first_in_rigid_mode
def test_tablerow_with_multiple_invalid_attributes_reports_first_in_strict2_mode
template = '{% tablerow i in (1..10) invalid1: 5, invalid2: 10 %}{{ i }}{% endtablerow %}'
with_error_modes(:rigid) do
with_error_modes(:strict2) do
error = assert_raises(SyntaxError) { Template.parse(template) }
assert_equal("Liquid syntax error: Invalid attribute 'invalid1' in tablerow loop. Valid attributes are cols, limit, offset, and range in \"i in (1..10) invalid1: 5, invalid2: 10\"", error.message)
end
end
def test_tablerow_with_empty_collection_in_rigid_mode
def test_tablerow_with_empty_collection_in_strict2_mode
template = <<~LIQUID.chomp
{% tablerow i in empty_array cols: 2 %}{{ i }}{% endtablerow %}
LIQUID
@@ -426,12 +426,12 @@ class TableRowTest < Minitest::Test
</tr>
OUTPUT
with_error_modes(:rigid) do
with_error_modes(:strict2) do
assert_template_result(expected, template, { 'empty_array' => [] })
end
end
def test_tablerow_with_invalid_attribute_strict_vs_rigid
def test_tablerow_with_invalid_attribute_strict_vs_strict2
template = '{% tablerow i in (1..5) invalid_attr: 10 %}{{ i }}{% endtablerow %}'
expected = <<~OUTPUT
@@ -443,13 +443,13 @@ class TableRowTest < Minitest::Test
assert_template_result(expected, template)
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
error = assert_raises(SyntaxError) { Template.parse(template) }
assert_match(/Invalid attribute 'invalid_attr'/, error.message)
end
end
def test_tablerow_with_invalid_expression_strict_vs_rigid
def test_tablerow_with_invalid_expression_strict_vs_strict2
template = '{% tablerow i in (1..5) limit: foo=>bar %}{{ i }}{% endtablerow %}'
with_error_modes(:lax, :strict) do
@@ -460,7 +460,7 @@ class TableRowTest < Minitest::Test
assert_template_result(expected, template)
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
error = assert_raises(SyntaxError) { Template.parse(template) }
assert_match(/Unexpected character =/, error.message)
end
+5 -5
View File
@@ -218,7 +218,7 @@ class VariableTest < Minitest::Test
assert_match(/is not a valid expression/, error.message)
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
assert_template_result('helloworld', template)
end
end
@@ -231,7 +231,7 @@ class VariableTest < Minitest::Test
assert_match(/is not a valid expression/, error.message)
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
assert_template_result('hello12', template)
end
end
@@ -244,7 +244,7 @@ class VariableTest < Minitest::Test
assert_match(/is not a valid expression/, error.message)
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
assert_template_result('TEST', template)
end
end
@@ -257,7 +257,7 @@ class VariableTest < Minitest::Test
assert_match(/is not a valid expression/, error.message)
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
assert_template_result('TESTX', template)
end
end
@@ -270,7 +270,7 @@ class VariableTest < Minitest::Test
assert_match(/is not a valid expression/, error.message)
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
assert_template_result('TESTX', template)
end
end
+5 -5
View File
@@ -176,19 +176,19 @@ class ConditionUnitTest < Minitest::Test
assert_equal(['title'], result.lookups)
end
def test_parse_expression_in_rigid_mode_raises_internal_error
environment = Environment.build(error_mode: :rigid)
def test_parse_expression_in_strict2_mode_raises_internal_error
environment = Environment.build(error_mode: :strict2)
parse_context = ParseContext.new(environment: environment)
error = assert_raises(Liquid::InternalError) do
Condition.parse_expression(parse_context, 'product.title')
end
assert_match(/unsafe parse_expression cannot be used in rigid mode/, error.message)
assert_match(/unsafe parse_expression cannot be used in strict2 mode/, error.message)
end
def test_parse_expression_with_safe_true_in_rigid_mode
environment = Environment.build(error_mode: :rigid)
def test_parse_expression_with_safe_true_in_strict2_mode
environment = Environment.build(error_mode: :strict2)
parse_context = ParseContext.new(environment: environment)
result = Condition.parse_expression(parse_context, 'product.title', safe: true)
+27 -27
View File
@@ -9,32 +9,32 @@ class ParseContextUnitTest < Minitest::Test
parser_strict = strict_parse_context.new_parser('product.title')
result_strict = strict_parse_context.safe_parse_expression(parser_strict)
parser_rigid = rigid_parse_context.new_parser('product.title')
result_rigid = rigid_parse_context.safe_parse_expression(parser_rigid)
parser_strict2 = strict2_parse_context.new_parser('product.title')
result_strict2 = strict2_parse_context.safe_parse_expression(parser_strict2)
assert_instance_of(VariableLookup, result_strict)
assert_equal('product', result_strict.name)
assert_equal(['title'], result_strict.lookups)
assert_instance_of(VariableLookup, result_rigid)
assert_equal('product', result_rigid.name)
assert_equal(['title'], result_rigid.lookups)
assert_instance_of(VariableLookup, result_strict2)
assert_equal('product', result_strict2.name)
assert_equal(['title'], result_strict2.lookups)
end
def test_safe_parse_expression_raises_syntax_error_for_invalid_expression
parser_strict = strict_parse_context.new_parser('')
parser_rigid = rigid_parse_context.new_parser('')
parser_strict2 = strict2_parse_context.new_parser('')
error_strict = assert_raises(Liquid::SyntaxError) do
strict_parse_context.safe_parse_expression(parser_strict)
end
assert_match(/is not a valid expression/, error_strict.message)
error_rigid = assert_raises(Liquid::SyntaxError) do
rigid_parse_context.safe_parse_expression(parser_rigid)
error_strict2 = assert_raises(Liquid::SyntaxError) do
strict2_parse_context.safe_parse_expression(parser_strict2)
end
assert_match(/is not a valid expression/, error_rigid.message)
assert_match(/is not a valid expression/, error_strict2.message)
end
def test_parse_expression_with_variable_lookup
@@ -45,10 +45,10 @@ class ParseContextUnitTest < Minitest::Test
assert_equal(['title'], result_strict.lookups)
error = assert_raises(Liquid::InternalError) do
rigid_parse_context.parse_expression('product.title')
strict2_parse_context.parse_expression('product.title')
end
assert_match(/unsafe parse_expression cannot be used in rigid mode/, error.message)
assert_match(/unsafe parse_expression cannot be used in strict2 mode/, error.message)
end
def test_parse_expression_with_safe_true
@@ -58,11 +58,11 @@ class ParseContextUnitTest < Minitest::Test
assert_equal('product', result_strict.name)
assert_equal(['title'], result_strict.lookups)
result_rigid = rigid_parse_context.parse_expression('product.title', safe: true)
result_strict2 = strict2_parse_context.parse_expression('product.title', safe: true)
assert_instance_of(VariableLookup, result_rigid)
assert_equal('product', result_rigid.name)
assert_equal(['title'], result_rigid.lookups)
assert_instance_of(VariableLookup, result_strict2)
assert_equal('product', result_strict2.name)
assert_equal(['title'], result_strict2.lookups)
end
def test_parse_expression_with_empty_string
@@ -70,40 +70,40 @@ class ParseContextUnitTest < Minitest::Test
assert_nil(result_strict)
error = assert_raises(Liquid::InternalError) do
rigid_parse_context.parse_expression('')
strict2_parse_context.parse_expression('')
end
assert_match(/unsafe parse_expression cannot be used in rigid mode/, error.message)
assert_match(/unsafe parse_expression cannot be used in strict2 mode/, error.message)
end
def test_parse_expression_with_empty_string_and_safe_true
result_strict = strict_parse_context.parse_expression('', safe: true)
assert_nil(result_strict)
result_rigid = rigid_parse_context.parse_expression('', safe: true)
assert_nil(result_rigid)
result_strict2 = strict2_parse_context.parse_expression('', safe: true)
assert_nil(result_strict2)
end
def test_safe_parse_expression_advances_parser_pointer
parser = rigid_parse_context.new_parser('foo, bar')
parser = strict2_parse_context.new_parser('foo, bar')
# safe_parse_expression consumes "foo"
first_result = rigid_parse_context.safe_parse_expression(parser)
first_result = strict2_parse_context.safe_parse_expression(parser)
assert_instance_of(VariableLookup, first_result)
assert_equal('foo', first_result.name)
parser.consume(:comma)
# safe_parse_expression consumes "bar"
second_result = rigid_parse_context.safe_parse_expression(parser)
second_result = strict2_parse_context.safe_parse_expression(parser)
assert_instance_of(VariableLookup, second_result)
assert_equal('bar', second_result.name)
parser.consume(:end_of_string)
end
def test_parse_expression_with_whitespace_in_rigid_mode
result = rigid_parse_context.parse_expression(' ', safe: true)
def test_parse_expression_with_whitespace_in_strict2_mode
result = strict2_parse_context.parse_expression(' ', safe: true)
assert_nil(result)
end
@@ -115,9 +115,9 @@ class ParseContextUnitTest < Minitest::Test
)
end
def rigid_parse_context
@rigid_parse_context ||= ParseContext.new(
environment: Environment.build(error_mode: :rigid),
def strict2_parse_context
@strict2_parse_context ||= ParseContext.new(
environment: Environment.build(error_mode: :strict2),
)
end
end
+2 -2
View File
@@ -184,7 +184,7 @@ class PartialCacheUnitTest < Minitest::Test
},
)
[:lax, :warn, :strict, :rigid].each do |error_mode|
[:lax, :warn, :strict, :strict2].each do |error_mode|
Liquid::PartialCache.load(
'my_partial',
context: context,
@@ -193,7 +193,7 @@ class PartialCacheUnitTest < Minitest::Test
end
assert_equal(
["my_partial:lax", "my_partial:warn", "my_partial:strict", "my_partial:rigid"],
["my_partial:lax", "my_partial:warn", "my_partial:strict", "my_partial:strict2"],
context.registers[:cached_partials].keys,
)
end
+6 -6
View File
@@ -24,7 +24,7 @@ class CaseTagUnitTest < Minitest::Test
assert_template_result("one", template)
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
error = assert_raises(Liquid::SyntaxError) { Template.parse(template) }
assert_match(/Expected end_of_string but found/, error.message)
@@ -45,7 +45,7 @@ class CaseTagUnitTest < Minitest::Test
assert_template_result("one", template)
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
error = assert_raises(Liquid::SyntaxError) { Template.parse(template) }
assert_match(/Expected end_of_string but found/, error.message)
@@ -62,7 +62,7 @@ class CaseTagUnitTest < Minitest::Test
{%- endcase -%}
LIQUID
with_error_modes(:lax, :strict, :rigid) do
with_error_modes(:lax, :strict, :strict2) do
assert_template_result("one", template)
end
end
@@ -77,7 +77,7 @@ class CaseTagUnitTest < Minitest::Test
{%- endcase -%}
LIQUID
with_error_modes(:lax, :strict, :rigid) do
with_error_modes(:lax, :strict, :strict2) do
assert_template_result("one", template)
end
end
@@ -97,7 +97,7 @@ class CaseTagUnitTest < Minitest::Test
assert_template_result("one", template, assigns)
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
error = assert_raises(Liquid::SyntaxError) { Template.parse(template) }
assert_match(/Unexpected character =/, error.message)
@@ -119,7 +119,7 @@ class CaseTagUnitTest < Minitest::Test
assert_template_result("one", template, assigns)
end
with_error_modes(:rigid) do
with_error_modes(:strict2) do
error = assert_raises(Liquid::SyntaxError) { Template.parse(template) }
assert_match(/Unexpected character =/, error.message)
+2 -2
View File
@@ -161,8 +161,8 @@ class VariableUnitTest < Minitest::Test
end
end
def test_rigid_filter_argument_parsing
with_error_modes(:rigid) do
def test_strict2_filter_argument_parsing
with_error_modes(:strict2) do
# optional colon
var = create_variable(%(n | f1 | f2:))
assert_equal([['f1', []], ['f2', []]], var.filters)