mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-12 23:40:45 -07:00
Extract Parser#string out of Expression.parse
This commit is contained in:
+11
-1
@@ -48,7 +48,17 @@ module Liquid
|
||||
end
|
||||
|
||||
def expression
|
||||
parse_expression(expression_string)
|
||||
token = @tokens[@p]
|
||||
case token[0]
|
||||
when :string
|
||||
string
|
||||
else
|
||||
parse_expression(expression_string)
|
||||
end
|
||||
end
|
||||
|
||||
def string
|
||||
consume(:string)[1..-2]
|
||||
end
|
||||
|
||||
def argument_string
|
||||
|
||||
@@ -58,6 +58,14 @@ class ParserUnitTest < Minitest::Test
|
||||
assert_equal('"wut"', p.expression_string)
|
||||
end
|
||||
|
||||
def test_string
|
||||
p = new_parser("'s1' \"s2\" 'this \"s3\"' \"that 's4'\"")
|
||||
assert_equal('s1', p.string)
|
||||
assert_equal('s2', p.string)
|
||||
assert_equal('this "s3"', p.string)
|
||||
assert_equal("that 's4'", p.string)
|
||||
end
|
||||
|
||||
def test_ranges
|
||||
p = new_parser("(5..7) (1.5..9.6) (young..old) (hi[5].wat..old)")
|
||||
assert_equal('(5..7)', p.expression_string)
|
||||
|
||||
Reference in New Issue
Block a user