Skip to content

Commit d109bc9

Browse files
committed
Remove unneeded read method
1 parent 47288cc commit d109bc9

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

lib/liquid/parser.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ def jump(point)
1212
@p = point
1313
end
1414

15-
def read(type = nil)
16-
token = @tokens[@p]
17-
if type && token[0] != type
18-
raise SyntaxError, "Expected #{type} but found #{@tokens[@p].first}"
19-
end
20-
token[1]
21-
end
22-
2315
def consume(type = nil)
2416
token = @tokens[@p]
2517
if type && token[0] != type

lib/liquid/tags/render.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def rigid_template_name(p)
113113
return p.consume(:string) if p.look(:string)
114114
return p.consume(:id) if p.look(:id)
115115

116-
found = p.look(:end_of_string) ? "nothing" : p.read
116+
found = p.consume || "nothing"
117117
raise SyntaxError, options[:locale].t("errors.syntax.render_invalid_template_name", found: found)
118118
end
119119

test/integration/tags/snippet_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,16 @@ def test_render_with_no_identifier
953953

954954
assert_match("Expected a string or identifier, found nothing", exception.message)
955955
end
956+
957+
def test_render_with_invalid_identifier
958+
template = "{% render 123 %}"
959+
960+
exception = assert_raises(SyntaxError) do
961+
Liquid::Template.parse(template, error_mode: :rigid)
962+
end
963+
964+
assert_match("Expected a string or identifier, found 123", exception.message)
965+
end
956966
end
957967

958968
class ResourceLimits < SnippetTest

0 commit comments

Comments
 (0)