mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-20 11:20:41 -07:00
Remove unneeded read method
This commit is contained in:
committed by
Guilherme Carreiro
parent
ae05ba071c
commit
98fbd985d8
@@ -12,14 +12,6 @@ module Liquid
|
|||||||
@p = point
|
@p = point
|
||||||
end
|
end
|
||||||
|
|
||||||
def read(type = nil)
|
|
||||||
token = @tokens[@p]
|
|
||||||
if type && token[0] != type
|
|
||||||
raise SyntaxError, "Expected #{type} but found #{@tokens[@p].first}"
|
|
||||||
end
|
|
||||||
token[1]
|
|
||||||
end
|
|
||||||
|
|
||||||
def consume(type = nil)
|
def consume(type = nil)
|
||||||
token = @tokens[@p]
|
token = @tokens[@p]
|
||||||
if type && token[0] != type
|
if type && token[0] != type
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ module Liquid
|
|||||||
return p.consume(:string) if p.look(:string)
|
return p.consume(:string) if p.look(:string)
|
||||||
return p.consume(:id) if p.look(:id)
|
return p.consume(:id) if p.look(:id)
|
||||||
|
|
||||||
found = p.look(:end_of_string) ? "nothing" : p.read
|
found = p.consume || "nothing"
|
||||||
raise SyntaxError, options[:locale].t("errors.syntax.render_invalid_template_name", found: found)
|
raise SyntaxError, options[:locale].t("errors.syntax.render_invalid_template_name", found: found)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -953,6 +953,16 @@ class SnippetTest < Minitest::Test
|
|||||||
|
|
||||||
assert_match("Expected a string or identifier, found nothing", exception.message)
|
assert_match("Expected a string or identifier, found nothing", exception.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_render_with_invalid_identifier
|
||||||
|
template = "{% render 123 %}"
|
||||||
|
|
||||||
|
exception = assert_raises(SyntaxError) do
|
||||||
|
Liquid::Template.parse(template, error_mode: :rigid)
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_match("Expected a string or identifier, found 123", exception.message)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class ResourceLimits < SnippetTest
|
class ResourceLimits < SnippetTest
|
||||||
|
|||||||
Reference in New Issue
Block a user