Tokens
liquid.Token
Bases: NamedTuple
A substring into Liquid template source text along with its type.
kind
instance-attribute
The type of the token.
Could be one of TOKEN_TAG
, TOKEN_OUTPUT
, TOKEN_EXPRESSION
or TOKEN_CONTENT
indicating that it is a "top-level" token. All other tokens kinds are for tag and
output expressions.
source
instance-attribute
A reference to the template source text from which this token came.
liquid.TokenStream
Step through a sequence of tokens.
eat
Consume and return the next token.
If the type of the next token is equal to typ, raise an exceptions.
This is equivalent to stream.expect(typ)
followed by next(stream)
.
eat_one_of
Consume and return the next token.
If the type of the next token is equal to typ, raise an exceptions.
This is equivalent to stream.expect(typ)
followed by next(stream)
.
expect
Check the current token in the stream matches the given type and value.
Returns the current token if its type matches typ.
Raises a LiquidSyntaxError
if it doesn't.
expect_peek
Check the next token in the stream matches the given type and value.
Returns the next token if its type matches typ.
Raises a LiquidSyntaxError
it doesn't.
into_inner
Return a stream of tokens for the current expression token.
If the current token is not an expression, a LiquidSyntaxError
is
raised.
If tag is given, it will be used to add context information to the syntax error, should one be raised.
If eat is true (the default), the current token is consumed.