liquid.liquid
liquid.liquid.Liquid(template, from_file=None, mode=None, env=None, filter_with_colon=None, search_paths=None, globals=None, filters=None, filters_as_globals=None, **kwargs)
The entrance for the package
>>> Liquid('{{a}}', from_file=False)>>> Liquid('template.html')
template(PathLike or str) — The template string or path of the template filefrom_file(bool, optional) — Whethertemplateis a file path. If True, aFileSystemLoaderwill be used in theenv.mode(str, optional) — The mode of the engine.- - standard: Most compatibility with the standard liquid engine
- - jekyll: The jekyll-compatible mode
- - shopify: The shopify-compatible mode
- - wild: The liquid- and jinja-compatible mode
env(Environment, optional) — The jinja environmentfilter_with_colon(bool, optional) — Whether enable to use colon to separate filter andits arguments (i.e.{{a | filter: arg}}). If False, will fallback to use parentheses ({{a | filter(arg)}})search_paths(Union(pathlike, str, iterable of pathlike or str), optional) — The search paths for the template files.This only supports specification of paths. If you need so specifyencodingand/orfollowlinks, you should use jinja'sFileSystemLoaderglobals(optional) — Additional global values to be used to render the templatefilters(optional) — Additional filters be to used to render the templatefilters_as_globals(bool, optional) — Whether also use filters as globalsOnly works in wild mode**kwargs(any) — Other arguments for an jinja Environment construction andconfigurations for extensions
render(*args, **kwargs) → any
Render the template.
You can either pass the values using tpl.render(a=1) or
tpl.render({'a': 1})
render_async(*args, **kwargs) → any
Asynchronously render the template
from_env(template, env, from_file=None, filter_with_colon=None, filters_as_globals=None, mode=None) → Liquid
Initiate a template from a jinja environment
You should not specify any liquid-related extensions here. They will be added automatically.
No search path is allow to be passed here. Instead, use jinja2's loaders or use the constructor to initialize a template.
@Args:
template: The template string or path of the template file
env: The jinja environment
from_file: Whether template is a file path. If True, a
FileSystemLoader will be used in the env.
filter_with_colon: Whether enable to use colon to separate filter
and its arguments (i.e. {{a | filter: arg}}). If False, will
fallback to use parentheses ({{a | filter(arg)}})
filters_as_globals: Whether also use filters as globals
Only works in wild mode
mode: The mode of the engine.
- standard: Most compatibility with the standard liquid engine
- wild: The liquid- and jinja-compatible mode
- jekyll: The jekyll-compatible mode
@Returns:
A Liquid object