From af774ebc55c5c35e091b7ad950c0e721074986b6 Mon Sep 17 00:00:00 2001 From: "Charles-P. Clermont" Date: Tue, 2 Dec 2025 16:14:22 -0500 Subject: [PATCH] Replace RangeLookup.parse with RangeLookup.create --- lib/liquid/expression.rb | 16 ++++++++++------ lib/liquid/range_lookup.rb | 4 +--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/liquid/expression.rb b/lib/liquid/expression.rb index e3091dc1..1bf7edcf 100644 --- a/lib/liquid/expression.rb +++ b/lib/liquid/expression.rb @@ -48,12 +48,16 @@ module Liquid end def inner_parse(markup, ss, cache) - if markup.start_with?("(") && markup.end_with?(")") && markup =~ RANGES_REGEX - return RangeLookup.parse( - Regexp.last_match(1), - Regexp.last_match(2), - ss, - cache, + if (markup.start_with?("(") && markup.end_with?(")")) && markup =~ RANGES_REGEX + start_markup = Regexp.last_match(1) + end_markup = Regexp.last_match(2) + start_obj = parse(start_markup, ss, cache) + end_obj = parse(end_markup, ss, cache) + return RangeLookup.create( + start_obj, + end_obj, + start_markup, + end_markup, ) end diff --git a/lib/liquid/range_lookup.rb b/lib/liquid/range_lookup.rb index bc316fe1..e4ce296c 100644 --- a/lib/liquid/range_lookup.rb +++ b/lib/liquid/range_lookup.rb @@ -2,9 +2,7 @@ module Liquid class RangeLookup - def self.parse(start_markup, end_markup, string_scanner, cache = nil) - start_obj = Expression.parse(start_markup, string_scanner, cache) - end_obj = Expression.parse(end_markup, string_scanner, cache) + def self.create(start_obj, end_obj, start_markup, end_markup) if start_obj.respond_to?(:evaluate) || end_obj.respond_to?(:evaluate) new(start_obj, end_obj) else