mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-26 13:45:13 -07:00
more opt
This commit is contained in:
committed by
Michael Go
parent
f42c6b0608
commit
d76663f570
+10
-6
@@ -10,9 +10,9 @@ module Liquid
|
|||||||
TAG_OR_VARIABLE_START = /\{[\{\%}]/
|
TAG_OR_VARIABLE_START = /\{[\{\%}]/
|
||||||
NEWLINE = /\n/
|
NEWLINE = /\n/
|
||||||
|
|
||||||
OPEN_CURLEY = 123
|
OPEN_CURLEY = "{".ord
|
||||||
CLOSE_CURLEY = 125
|
CLOSE_CURLEY = "}".ord
|
||||||
PERCENTAGE = 37
|
PERCENTAGE = "%".ord
|
||||||
|
|
||||||
def initialize(source, line_numbers = false, line_number: nil, for_liquid_tag: false)
|
def initialize(source, line_numbers = false, line_number: nil, for_liquid_tag: false)
|
||||||
@line_number = line_number || (line_numbers ? 1 : nil)
|
@line_number = line_number || (line_numbers ? 1 : nil)
|
||||||
@@ -90,8 +90,9 @@ module Liquid
|
|||||||
|
|
||||||
# it is possible to see a {% before a }} so we need to check for that
|
# it is possible to see a {% before a }} so we need to check for that
|
||||||
byte_a = @ss.scan_byte
|
byte_a = @ss.scan_byte
|
||||||
|
byte_b = byte_a
|
||||||
|
|
||||||
until @ss.eos?
|
while byte_b
|
||||||
byte_a = @ss.scan_byte while byte_a && byte_a != CLOSE_CURLEY && byte_a != OPEN_CURLEY
|
byte_a = @ss.scan_byte while byte_a && byte_a != CLOSE_CURLEY && byte_a != OPEN_CURLEY
|
||||||
|
|
||||||
break unless byte_a
|
break unless byte_a
|
||||||
@@ -115,8 +116,11 @@ module Liquid
|
|||||||
|
|
||||||
def next_tag_token
|
def next_tag_token
|
||||||
start = @ss.pos - 2
|
start = @ss.pos - 2
|
||||||
len = @ss.skip_until(TAG_END) || 0
|
if (len = @ss.skip_until(TAG_END))
|
||||||
@source.byteslice(start, len + 2)
|
@source.byteslice(start, len + 2)
|
||||||
|
else
|
||||||
|
"{%"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def next_tag_token_with_start(start)
|
def next_tag_token_with_start(start)
|
||||||
|
|||||||
Reference in New Issue
Block a user