Skip to main content

Module template

Module template 

Source
Expand description

The template language shared by webhook templates, provider definitions and gateways: Jinja syntax on minijinja, with SendMock’s filters and functions (12).

Structs§

RenderedTemplate
StandardTemplateFunctions
The time and random functions of 12, over the clock and random source so tests are deterministic.
TemplateFilterEntry
One filter as the reference documents it.
TemplateProblem

Enums§

TemplateEscape
How rendered values are written: as they are, or escaped for a place inside a JSON string, so a message body with quotes keeps a JSON answer valid.
TemplateProblemSeverity
TemplateRenderMode
Lenient renders an undefined value as nothing with a warning; strict stops with an error.

Constants§

BUILTIN_FILTER_NAMES
The minijinja built-in filters templates may use, beside SendMock’s own.
FAKE_METHOD_NAMES
Every fake.* method, as fake.<method>() in templates.
MAXIMUM_RENDERED_BYTES
The largest text one render may produce (1 MB), so a bad template cannot fill memory.
POSTMAN_ALIASES
Each Postman name and the expression it stands for.
SENDMOCK_FILTER_NAMES
SendMock’s filters, registered in template_environment.
TEMPLATE_FILTER_CATALOGUE
Every filter in SENDMOCK_FILTER_NAMES, in the same order.
TEMPLATE_FUEL_LIMIT
Instructions one render may run, so a runaway loop stops instead of hanging a delivery.

Traits§

TemplateFunctions
The functions a template may call, such as uuid(). Keyword arguments arrive as one object after the positional ones.

Functions§

evaluate_template_expression
Evaluates one expression, such as data.to[0].address | lower or random_int(1, 9), and keeps its type: a number stays a number and a list stays a list. A missing value is null.
generate_uuid_v4
A version 4 UUID.
render_template
Renders leniently, as the UI preview does: an undefined value renders empty with a warning.
render_template_in_mode
Renders in a mode. Unknown names and unbalanced braces are found before rendering and stop it (the text is returned as written); a failed render returns no text.