liquid.utils
Some utils
Functions
parse_tag_args
(
stream
,name
,lineno
)
(Node) — Parse arguments for a tag.</>peek_tokens
(
stream
,n
)
(list of Token) — Peek ahead 'n' tokens in the token stream, but don't move the cursor</>
function
liquid.utils.
peek_tokens
(
stream
, n=1
)
Peek ahead 'n' tokens in the token stream, but don't move the cursor
Parameters
stream
(TokenStream) — The token streamn
(int, optional) — n tokens to look at
Returns (list of Token)
List of n tokens ahead.
function
liquid.utils.
parse_tag_args
(
stream
, name
, lineno
)
Parse arguments for a tag.
Only integer and name are allowed as values
Examples
>>> "{{tablerow product in products cols:2}}">>> parse_tag_args(stream, "cols", lineno)
>>> # returns nodes.Const(2)
Parameters
stream
(TokenStream) — The token streamname
(str) — The name of the argumentlineno
(int) — The lineno
Returns (Node)
None if the argument is not pressent otherwise a Const or Name node