File tree Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Expand file tree Collapse file tree 3 files changed +11
-9
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments