mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-29 15:15:19 -07:00
use String#split for liquid tag tokenization
This commit is contained in:
+1
-23
@@ -84,9 +84,7 @@ module Liquid
|
|||||||
|
|
||||||
def tokenize
|
def tokenize
|
||||||
if @for_liquid_tag
|
if @for_liquid_tag
|
||||||
until @ss.eos?
|
@tokens = @source.split("\n")
|
||||||
@tokens << shift_liquid_tag
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
until @ss.eos?
|
until @ss.eos?
|
||||||
@tokens << shift_normal
|
@tokens << shift_normal
|
||||||
@@ -104,26 +102,6 @@ module Liquid
|
|||||||
token
|
token
|
||||||
end
|
end
|
||||||
|
|
||||||
def shift_liquid_tag
|
|
||||||
token = next_liquid_token
|
|
||||||
|
|
||||||
return unless token
|
|
||||||
|
|
||||||
token
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_liquid_token
|
|
||||||
# read until we find a \n
|
|
||||||
start = @ss.pos
|
|
||||||
if @ss.skip_until(NEWLINE).nil?
|
|
||||||
token = @ss.rest
|
|
||||||
@ss.terminate
|
|
||||||
return token
|
|
||||||
end
|
|
||||||
|
|
||||||
@source.byteslice(start, @ss.pos - start - 1)
|
|
||||||
end
|
|
||||||
|
|
||||||
def next_token
|
def next_token
|
||||||
# possible states: :text, :tag, :variable
|
# possible states: :text, :tag, :variable
|
||||||
byte_a = @ss.peek_byte
|
byte_a = @ss.peek_byte
|
||||||
|
|||||||
Reference in New Issue
Block a user