liquid.Template
A factory function. Create a liquid.template.BoundTemplate
, automatically creating a liquid.Environment
to bind it to.
Template
Template(source, [options]) -> liquid.template.BoundTemplate
Parameters:
-
source: str
- The liquid template source code. -
tag_start_string: str
- The sequence of characters indicating the start of a liquid tag. Defaults to{%
. -
tag_end_string: str
- The sequence of characters indicating the end of a liquid tag. Defaults to%}
. -
statement_start_string: str
- The sequence of characters indicating the start of an output statement. Defaults to{{
. -
statement_end_string: str
- The sequence of characters indicating the end of an output statement. Defaults to}}
. -
comment_start_string: str
- The sequence of characters indicating the start of a comment. Defaults to{#
.template_comments
must beTrue
forcomment_start_string
to have any effect. -
comment_end_string: str
- The sequence of characters indicating the end of a comment. Defaults to#}
.template_comments
must beTrue
forcomment_end_string
to have any effect. -
template_comments: bool
- IfTrue
, enable template comments. Where, by default, anything between{#
and#}
is considered a comment. Defaults toFalse
. -
tolerance: Mode
- Indicates how tolerant to be of errors. Must be one ofMode.LAX
,Mode.WARN
orMode.STRICT
. Defaults toMode.STRICT
. -
undefined: liquid.Undefined
- A subclass of Undefined that represents undefined values. Could be one of the built-in undefined types, Undefined, DebugUndefined or StrictUndefined. Defaults toUndefined
, an undefined type that silently ignores undefined values. -
strict_filters: bool
- IfTrue
, will raise an exception upon finding an undefined filter. Otherwise undefined filters are silently ignored. Defaults toTrue
. -
autoescape: bool
- IfTrue
, all context values will be HTML-escaped before output unless they've been explicitly marked as "safe". Requires the package Markupsafe. Defaults toFalse
. -
auto_reload: bool
- IfTrue
, loaders that have anuptodate
callable will reload template source data automatically. For deployments where template sources don't change between service reloads, setting auto_reload to False can yield an increase in performance by avoiding calls touptodate
. Defaults toTrue
. -
cache_size: int
- The capacity of the template cache in number of templates. Defaults to300
. Ifcache_size
isNone
or less than1
, it has the effect of settingauto_reload
toFalse
. -
expression_cache_size: int
- The capacity of each of the common expression caches. Defaults to0
, disabling expression caching. -
globals: Optional[Mapping[str, object]]
- An optional mapping that will be added to the context every time the resultingBoundTemplate
is rendered. Defaults toNone
.
Return type: liquid.template.BoundTemplate