expose expression_cache/string_scanner via attr_reader, skip regex in filter args without colon

This commit is contained in:
Tobi Lutke
2026-03-11 07:38:16 -04:00
parent 8a92a4e451
commit 2d3b856b36
2 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
module Liquid module Liquid
class ParseContext class ParseContext
attr_accessor :locale, :line_number, :trim_whitespace, :depth attr_accessor :locale, :line_number, :trim_whitespace, :depth
attr_reader :partial, :warnings, :error_mode, :environment attr_reader :partial, :warnings, :error_mode, :environment, :expression_cache, :string_scanner
def initialize(options = Const::EMPTY_HASH) def initialize(options = Const::EMPTY_HASH)
@environment = options.fetch(:environment, Environment.default) @environment = options.fetch(:environment, Environment.default)
+4 -3
View File
@@ -143,8 +143,8 @@ module Liquid
# Resolve the name expression # Resolve the name expression
expr_markup = markup.byteslice(name_start, name_end - name_start) expr_markup = markup.byteslice(name_start, name_end - name_start)
cache = parse_context.instance_variable_get(:@expression_cache) cache = parse_context.expression_cache
ss = parse_context.instance_variable_get(:@string_scanner) ss = parse_context.string_scanner
if Expression::LITERALS.key?(expr_markup) if Expression::LITERALS.key?(expr_markup)
@name = Expression::LITERALS[expr_markup] @name = Expression::LITERALS[expr_markup]
@@ -300,7 +300,8 @@ module Liquid
filter_args = [] filter_args = []
keyword_args = nil keyword_args = nil
unparsed_args.each do |a| unparsed_args.each do |a|
if (matches = a.match(JustTagAttributes)) # Fast check: keyword args must contain ':'
if a.include?(':') && (matches = a.match(JustTagAttributes))
keyword_args ||= {} keyword_args ||= {}
keyword_args[matches[1]] = parse_context.parse_expression(matches[2]) keyword_args[matches[1]] = parse_context.parse_expression(matches[2])
else else