Convenience functions
liquid2.parse
Parse source as a Liquid template using the default environment.
PARAMETER | DESCRIPTION |
---|---|
source
|
Liquid template source code.
TYPE:
|
name
|
An optional name for the template used in error messages.
TYPE:
|
globals
|
Variables that will be available to the resulting template.
TYPE:
|
Return
A new template bound to the default environment.
liquid2.render
Parse and render source as a Liquid template using the default environment.
Additional arguments are passed to dict()
and will be available as template
variables.
PARAMETER | DESCRIPTION |
---|---|
source
|
Liquid template source code.
TYPE:
|
*args
|
dict-like arguments added to the template render context.
TYPE:
|
**kwargs
|
dict-like arguments added to the template render context.
TYPE:
|
Return
The result of rendering source as a Liquid template.
liquid2.render_async
async
Parse and render source as a Liquid template using the default environment.
Additional arguments are passed to dict()
and will be available as template
variables.
PARAMETER | DESCRIPTION |
---|---|
source
|
Liquid template source code.
TYPE:
|
*args
|
dict-like arguments added to the template render context.
TYPE:
|
**kwargs
|
dict-like arguments added to the template render context.
TYPE:
|
Return
The result of rendering source as a Liquid template.
liquid2.extract_liquid
extract_liquid(
fileobj: TextIO,
keywords: list[str],
comment_tags: list[str] | None = None,
options: dict[object, object] | None = None,
) -> Iterator[MessageTuple]
A babel compatible translation message extraction method for Liquid templates.
See https://babel.pocoo.org/en/latest/messages.html
Keywords are the names of Liquid filters or tags operating on translatable
strings. For a filter to contribute to message extraction, it must also
appear as a child of a FilteredExpression
and be a TranslatableFilter
.
Similarly, tags must produce a node that is a TranslatableTag
.
Where a Liquid comment contains a prefix in comment_tags
, the comment
will be attached to the translatable filter or tag immediately following
the comment. Python Liquid's non-standard shorthand comments are not
supported.
Options are arguments passed to the liquid.Template
constructor with the
contents of fileobj
as the template's source. Use extract_from_template
to extract messages from an existing template bound to an existing
environment.