Skip to content

API Reference parrot.template.engine

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.template.engine

View source

Class JinjaConfig

Configuration for the async Jinja2 Environment.

Parameter Type Default Description
template_dirs list[Path] list()
extensions list[str] (lambda: ['jinja2.ext.i18n', 'jinja2.ext.loopcontrols', 'jinja2_time.TimeExtension', 'jinja2_iso8601.ISO8601Extension', 'jinja2.ext.do', 'jinja2_humanize_extension.HumanizeExtension'])()
bytecode_cache_dir Optional[Path] None
bytecode_cache_pattern str '%s.cache'
autoescape Any select_autoescape(['html', 'xml', 'j2', 'jinja', 'jinja2'])
undefined Any StrictUndefined
keep_trailing_newline bool True
trim_blocks bool True
lstrip_blocks bool True

Fields:

Field Type Default Description
template_dirs list[Path] field(default_factory=list)
extensions list[str] field(default_factory=lambda: ['jinja2.ext.i18n', 'jinja2.ext.loopcontrols', 'jinja2_time.TimeExtension', 'jinja2_iso8601.ISO8601Extension', 'jinja2.ext.do', 'jinja2_humanize_extension.HumanizeExtension'])
bytecode_cache_dir Optional[Path] None
bytecode_cache_pattern str '%s.cache'
autoescape Any select_autoescape(['html', 'xml', 'j2', 'jinja', 'jinja2'])
undefined Any StrictUndefined
keep_trailing_newline bool True
trim_blocks bool True
lstrip_blocks bool True

Attribute PathLike

Class TemplateEngine

Parameter Type Default Description
template_dirs Optional[Union[PathLike, Sequence[PathLike]]] None
extensions Optional[Sequence[str]] None
bytecode_cache_dir Optional[PathLike] None
filters Optional[Mapping[str, Any]] None
globals_ Optional[Mapping[str, Any]] None
config Optional[JinjaConfig] None
debug bool False

Method TemplateEngine.add_template_dir

Add a new filesystem directory to the search path at runtime.

add_template_dir(path: PathLike) -> None

Parameter Type Default Description
path PathLike

Method TemplateEngine.add_templates

Add/override in-memory templates. Example: add_templates({'layout.html': '{{ self.block() }}'})

add_templates(templates: Mapping[str, str]) -> None

Parameter Type Default Description
templates Mapping[str, str]

Method TemplateEngine.get_template

Get a compiled template by name (raises FileNotFoundError on miss).

get_template(name: str)

Parameter Type Default Description
name str

Method TemplateEngine.render

Async render of a template by name. Only async path is supported (no sync render).

render(name: str, params: Optional[Mapping[str, Any]] = None) -> str

Parameter Type Default Description
name str
params Optional[Mapping[str, Any]] None

Returns: str

Method TemplateEngine.render_string

Async render from a string (compiled via the current environment). Useful for ad-hoc/injected content.

render_string(source: str, params: Optional[Mapping[str, Any]] = None) -> str

Parameter Type Default Description
source str
params Optional[Mapping[str, Any]] None

Returns: str

Method TemplateEngine.add_filters

Register additional filters (supports async filters too).

add_filters(filters: Mapping[str, Any]) -> None

Parameter Type Default Description
filters Mapping[str, Any]

Method TemplateEngine.add_globals

Register additional global variables/functions.

add_globals(globals_: Mapping[str, Any]) -> None

Parameter Type Default Description
globals_ Mapping[str, Any]

Method TemplateEngine.compile_directory

Optionally precompile all templates from filesystem loaders into target. Skips silently if there are no filesystem directories.

compile_directory(target: PathLike, *, zip: Optional[str] = 'deflated') -> None

Parameter Type Default Description
target PathLike
zip Optional[str] 'deflated'

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally