mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 10:52:48 -07:00
Move safe_parse_expression into Parser.expression_node
- Make `Parser` accept the expression cache - Remove `safe_parse_expression` from `ParseContext` - Replace all usage of `safe_parse_expression` with `parser.expression_node`
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
|
||||
module Liquid
|
||||
class Parser
|
||||
def initialize(input)
|
||||
ss = input.is_a?(StringScanner) ? input : StringScanner.new(input)
|
||||
@tokens = Lexer.tokenize(ss)
|
||||
def initialize(input, expression_cache = nil)
|
||||
@ss = input.is_a?(StringScanner) ? input : StringScanner.new(input)
|
||||
@cache = expression_cache
|
||||
@tokens = Lexer.tokenize(@ss)
|
||||
@p = 0 # pointer to current location
|
||||
end
|
||||
|
||||
@@ -71,6 +72,11 @@ module Liquid
|
||||
end
|
||||
end
|
||||
|
||||
def expression_node
|
||||
expr = expression
|
||||
Expression.parse(expr, @ss, @cache)
|
||||
end
|
||||
|
||||
def argument
|
||||
str = +""
|
||||
# might be a keyword argument (identifier: expression)
|
||||
|
||||
Reference in New Issue
Block a user