Skip to content

AST

liquid2.Node

Bases: ABC

Base class for all template nodes.

blank instance-attribute

blank = True

If True, indicates that the node, when rendered, produces no output text or only whitespace.

The output node ({{ something }}) and echo tag are exception. Even if they evaluate to an empty or blank string, they are not considered "blank".

block_scope

block_scope() -> Iterable[Identifier]

Return variables this node adds to the node's block scope.

children

children(
    static_context: RenderContext,
    *,
    include_partials: bool = True
) -> Iterable[Node]

Return this node's children.

children_async async

children_async(
    static_context: RenderContext,
    *,
    include_partials: bool = True
) -> Iterable[Node]

An async version of children().

expressions

expressions() -> Iterable[Expression]

Return this node's expressions.

partial_scope

partial_scope() -> Partial | None

Return information about a partial template loaded by this node.

raise_for_disabled

raise_for_disabled(disabled_tags: set[str]) -> None

Raise a DisabledTagError if this node has a name in disabled_tags.

render

render(context: RenderContext, buffer: TextIO) -> int

Write this node's content to buffer.

render_async async

render_async(context: RenderContext, buffer: TextIO) -> int

Write this node's content to buffer.

render_to_output abstractmethod

render_to_output(
    context: RenderContext, buffer: TextIO
) -> int

Render the node to the output buffer.

Return

The number of "characters" written to the output buffer.

render_to_output_async async

render_to_output_async(
    context: RenderContext, buffer: TextIO
) -> int

An async version of render_to_output.

template_scope

template_scope() -> Iterable[Identifier]

Return variables this node adds to the template local scope.

liquid2.BlockNode

Bases: Node

A node containing a sequence of other nodes.

children

children(
    static_context: RenderContext,
    *,
    include_partials: bool = True
) -> Iterable[Node]

Return this node's children.

render_to_output

render_to_output(
    context: RenderContext, buffer: TextIO
) -> int

Render the node to the output buffer.

render_to_output_async async

render_to_output_async(
    context: RenderContext, buffer: TextIO
) -> int

Render the node to the output buffer.

liquid2.ConditionalBlockNode

Bases: Node

A node containing a sequence of other nodes guarded by a Boolean expression.

children

children(
    static_context: RenderContext,
    *,
    include_partials: bool = True
) -> Iterable[Node]

Return this node's children.

expressions

expressions() -> Iterable[Expression]

Return this node's expressions.

render_to_output

render_to_output(
    context: RenderContext, buffer: TextIO
) -> int

Render the node to the output buffer.

render_to_output_async async

render_to_output_async(
    context: RenderContext, buffer: TextIO
) -> int

Render the node to the output buffer.

liquid2.ast.Partial dataclass

Partial template meta data.

in_scope instance-attribute

in_scope: Iterable[Identifier]

Names that will be added to the partial template scope.

name instance-attribute

name: Expression

An expression resolving to the name associated with the partial template.

scope instance-attribute

scope: PartialScope

The kind of scope the partial template should have when loaded.

liquid2.ast.PartialScope

Bases: Enum

The kind of scope a partial template should have when loaded.