diff --git a/lib/liquid/expression.rb b/lib/liquid/expression.rb index e10f97939..4ee0621f8 100644 --- a/lib/liquid/expression.rb +++ b/lib/liquid/expression.rb @@ -81,16 +81,18 @@ def parse(markup) markup = markup.strip # markup can be a frozen string + if (markup.start_with?('"') && markup.end_with?('"')) || + (markup.start_with?("'") && markup.end_with?("'")) + return markup[1..-2] + end + return CACHE[markup] if CACHE.key?(markup) CACHE[markup] = inner_parse(markup) end def inner_parse(markup) - if (markup.start_with?('"') && markup.end_with?('"')) || - (markup.start_with?("'") && markup.end_with?("'")) - return markup[1..-2] - elsif (markup.start_with?("(") && markup.end_with?(")")) && markup =~ RANGES_REGEX + if (markup.start_with?("(") && markup.end_with?(")")) && markup =~ RANGES_REGEX return RangeLookup.parse(Regexp.last_match(1), Regexp.last_match(2)) end @@ -149,5 +151,5 @@ def parse_number(markup) end end - Expression = StringScanner.instance_methods.include?(:scan_byte) ? Expression2 : Expression1 + Expression = StringScanner.instance_methods.include?(:scan_byte) ? Expression2 : Expression11 end