Skip to content

liquid.utils

module

liquid.utils

Some utils

Functions
  • parse_tag_args(stream, name, lineno) (Optional) — Parse arguments for a tag.</>
  • peek_tokens(stream, n) (List) — 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 stream
  • n (int, optional) — n tokens to look at
Returns (List)

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 stream
  • name (str) — The name of the argument
  • lineno (int) — The lineno
Returns (Optional)

None if the argument is not pressent otherwise a Const or Name node