Skip to content

Commit

Permalink
Merge pull request #1833 from Shopify/fast-variable-parse
Browse files Browse the repository at this point in the history
Faster Variable BlockBody Matching
  • Loading branch information
ggmichaelgo authored Oct 28, 2024
2 parents 6d58c41 + fb6ac72 commit b419648
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/liquid/block_body.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,17 @@ def render_node(context, output, node)
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_end = parse_end - i + 1
markup = markup_end <= 0 ? "" : token.byteslice(i, markup_end)

return Variable.new(markup, parse_context)
end

BlockBody.raise_missing_variable_terminator(token, parse_context)
end

Expand Down

0 comments on commit b419648

Please sign in to comment.