faster BlockBody variable matching

This commit is contained in:
Michael Go
2024-10-25 15:22:56 -03:00
parent b3553787c8
commit cb16219552
+8 -2
View File
@@ -246,10 +246,16 @@ module Liquid
end
def create_variable(token, parse_context)
if token =~ ContentOfVariable
markup = Regexp.last_match(1)
if token.end_with?("}}")
i = 2
i = 3 if token[i] == "-"
parse_end = token.length - 3
parse_end -= 1 if token[parse_end] == "-"
markup = token[i..parse_end]
return Variable.new(markup, parse_context)
end
BlockBody.raise_missing_variable_terminator(token, parse_context)
end