Skip to content

Commit 200fa0c

Browse files
authored
Revert "Add end tag support (Shopify#1823)" (Shopify#1824)
This reverts commit 27ead51.
1 parent 27ead51 commit 200fa0c

File tree

10 files changed

+6
-61
lines changed

10 files changed

+6
-61
lines changed

lib/liquid/block.rb

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ def unknown_tag(tag_name, _markup, _tokenizer)
3434
end
3535

3636
# @api private
37-
def self.raise_unknown_tag(tag, block_name, block_delimiter, parse_context, supports_end_tag = true)
37+
def self.raise_unknown_tag(tag, block_name, block_delimiter, parse_context)
3838
if tag == 'else'
3939
raise SyntaxError, parse_context.locale.t(
4040
"errors.syntax.unexpected_else",
4141
block_name: block_name,
4242
)
4343
elsif tag.start_with?('end')
4444
raise SyntaxError, parse_context.locale.t(
45-
supports_end_tag ? "errors.syntax.invalid_delimiter" : "errors.syntax.invalid_delimiter_no_end",
45+
"errors.syntax.invalid_delimiter",
4646
tag: tag,
4747
block_name: block_name,
4848
block_delimiter: block_delimiter,
@@ -64,10 +64,6 @@ def block_delimiter
6464
@block_delimiter ||= "end#{block_name}"
6565
end
6666

67-
def supports_end_tag?
68-
true
69-
end
70-
7167
private
7268

7369
# @api public
@@ -85,7 +81,7 @@ def parse_body(body, tokens)
8581
body.parse(tokens, parse_context) do |end_tag_name, end_tag_params|
8682
@blank &&= body.blank?
8783

88-
return false if end_tag_name == block_delimiter || (supports_end_tag? && end_tag_name == 'end')
84+
return false if end_tag_name == block_delimiter
8985
raise_tag_never_closed(block_name) unless end_tag_name
9086

9187
# this tag is not registered with the system

lib/liquid/block_body.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def freeze
6868

6969
# @api private
7070
def self.unknown_tag_in_liquid_tag(tag, parse_context)
71-
Block.raise_unknown_tag(tag, 'liquid', '%}', parse_context, false)
71+
Block.raise_unknown_tag(tag, 'liquid', '%}', parse_context)
7272
end
7373

7474
# @api private

lib/liquid/locales/en.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
if: "Syntax Error in tag 'if' - Valid syntax: if [expression]"
1515
include: "Error in tag 'include' - Valid syntax: include '[template]' (with|for) [object|collection]"
1616
inline_comment_invalid: "Syntax error in tag '#' - Each line of comments must be prefixed by the '#' character"
17-
invalid_delimiter: "'%{tag}' is not a valid delimiter for %{block_name} tags. use end or %{block_delimiter}"
18-
invalid_delimiter_no_end: "'%{tag}' is not a valid delimiter for %{block_name} tags. use %{block_delimiter}"
17+
invalid_delimiter: "'%{tag}' is not a valid delimiter for %{block_name} tags. use %{block_delimiter}"
1918
render: "Syntax error in tag 'render' - Template name must be a quoted string"
2019
table_row: "Syntax Error in 'table_row loop' - Valid syntax: table_row [item] in [collection] cols=3"
2120
tag_never_closed: "'%{block_name}' tag was never closed"

lib/liquid/tags/comment.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ def render_to_output_buffer(_context, output)
2222
def unknown_tag(_tag, _markup, _tokens)
2323
end
2424

25-
def supports_end_tag?
26-
false
27-
end
28-
2925
def blank?
3026
true
3127
end

lib/liquid/tags/raw.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ def initialize(tag_name, markup, parse_context)
2222
ensure_valid_markup(tag_name, markup, parse_context)
2323
end
2424

25-
def supports_end_tag?
26-
false
27-
end
28-
2925
def parse(tokens)
3026
@body = +''
3127
while (token = tokens.shift)

test/integration/block_test.rb

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,9 @@
55
class BlockTest < Minitest::Test
66
include Liquid
77

8-
def test_simple_end_tag
9-
assert_template_result('you rock', '{% if true %}you rock{% end %}')
10-
assert_template_result('you rock', '{% if true %}{% unless false %}you rock{% end %}{% end %}')
11-
end
12-
138
def test_unexpected_end_tag
149
source = '{% if true %}{% endunless %}'
15-
assert_match_syntax_error("Liquid syntax error (line 1): 'endunless' is not a valid delimiter for if tags. use end or endif", source)
16-
end
17-
18-
def test_end_closes_closest_open_tag
19-
source = '{% if true %}{% unless true %}{% end %}{% endunless %}'
20-
assert_match_syntax_error("Liquid syntax error (line 1): 'endunless' is not a valid delimiter for if tags. use end or endif", source)
21-
end
22-
23-
# comments are special and can't be closed by `end`
24-
def test_unexpected_end_tag_comment
25-
source = '{% comment %}{% end %}'
26-
assert_match_syntax_error("Liquid syntax error (line 1): 'comment' tag was never closed", source)
27-
end
28-
29-
# raw is special and can't be closed by `end`
30-
def test_unexpected_end_tag_raw
31-
source = '{% raw %}{% end %}'
32-
assert_match_syntax_error("Liquid syntax error (line 1): 'raw' tag was never closed", source)
10+
assert_match_syntax_error("Liquid syntax error (line 1): 'endunless' is not a valid delimiter for if tags. use endif", source)
3311
end
3412

3513
def test_with_custom_tag

test/integration/tags/if_else_tag_test.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ def test_if
1212
' {% if true %} this text should go into the output {% endif %} ',
1313
)
1414
assert_template_result(' you rock ?', '{% if false %} you suck {% endif %} {% if true %} you rock {% endif %}?')
15-
assert_template_result(' you rock ?', '{% if false %} you suck {% endif %} {% if true %} you rock {% end %}?')
1615
end
1716

1817
def test_literal_comparisons

test/integration/tags/liquid_tag_test.rb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ def test_cannot_close_blocks_created_before_a_liquid_tag
106106
42
107107
{%- liquid endif -%}
108108
LIQUID
109-
assert_match_syntax_error("syntax error (line 3): 'end' is not a valid delimiter for liquid tags. use %}", <<~LIQUID)
110-
{%- if true -%}
111-
42
112-
{%- liquid end -%}
113-
LIQUID
114109
end
115110

116111
def test_liquid_tag_in_raw
@@ -128,15 +123,6 @@ def test_nested_liquid_tags
128123
endif
129124
-%}
130125
LIQUID
131-
132-
assert_template_result('good', <<~LIQUID)
133-
{%- liquid
134-
liquid
135-
if true
136-
echo "good"
137-
end
138-
-%}
139-
LIQUID
140126
end
141127

142128
def test_nested_liquid_tags_on_same_line

test/integration/tags/raw_tag_test.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ def test_tag_in_raw
1010
'{% comment %} test {% endcomment %}',
1111
'{% raw %}{% comment %} test {% endcomment %}{% endraw %}',
1212
)
13-
assert_template_result(
14-
'',
15-
'{% comment %} {% if true %}{% end %} {% endcomment %}',
16-
)
1713
end
1814

1915
def test_output_in_raw

test/integration/tags/standard_tag_test.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def test_has_a_block_which_does_nothing
3838
assert_template_result('', '{%comment%}{%blabla%}{%endcomment%}')
3939
assert_template_result('', '{% comment %}{% blabla %}{% endcomment %}')
4040
assert_template_result('', '{%comment%}{% endif %}{%endcomment%}')
41-
assert_template_result('', '{%comment%}{% end %}{%endcomment%}')
4241
assert_template_result('', '{% comment %}{% endwhatever %}{% endcomment %}')
4342
assert_template_result('', '{% comment %}{% raw %} {{%%%%}} }} { {% endcomment %} {% comment {% endraw %} {% endcomment %}')
4443
assert_template_result('', '{% comment %}{% " %}{% endcomment %}')

0 commit comments

Comments
 (0)