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

This commit is contained in:
Tobi Lutke
2026-04-04 17:33:53 -07:00
committed by Chris Pak
parent 543c1e1fe7
commit f388c873de
2 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
module Liquid
class ParseContext
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)
@environment = options.fetch(:environment, Environment.default)
+4 -3
View File
@@ -143,8 +143,8 @@ module Liquid
# Resolve the name expression
expr_markup = markup.byteslice(name_start, name_end - name_start)
cache = parse_context.instance_variable_get(:@expression_cache)
ss = parse_context.instance_variable_get(:@string_scanner)
cache = parse_context.expression_cache
ss = parse_context.string_scanner
if Expression::LITERALS.key?(expr_markup)
@name = Expression::LITERALS[expr_markup]
@@ -300,7 +300,8 @@ module Liquid
filter_args = []
keyword_args = nil
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[matches[1]] = parse_context.parse_expression(matches[2])
else