Skip to content

Templating

To declare or evaluate an expression surround it in double brackets: {{ and }}.

Templating works on input values which have a green bottom line such as Parameters, Headers, Variables, URL and Body of type form.

input value

It also works on body of text-based content types.

input text

It also allows to import modules such as Decimal on Script tab.

Raw strings

If the templating syntax it's not used, the value becomes a string.

Examples:

  • Hello World
  •  spaced foo 

Python expressions

Python expressions can be used on green text inputs. To use Python expressions, it should start with {{ and ends with }} without trailing spaces:

✅ Good examples:

  • {{ Decimal('0.1') }}
  • {{'no_space'}}
  • {{ 'Hello World' }}

🚫 Wrong examples:

  • {{ Decimal('0.1') }}

If a Python expression is used inside the Variable tab, it preserves it's type. Otherwise it's transformed to a string. In order to import the used libraries use scripting.

Jinja templates

It uses the Jinja templating syntax, in case of ambiguity use a Jinja comment.

✅ Recommended:

  • Hello {{ 'World' }}
  • {# jinja #}{{ 'Foo' | upper }}
  • {# jinja #}{{ 'Hello' }} {{ 'World' }}
  • {% if True %}yay{% endif %}

May work, but it's not recommended:

  • {{ 'Hello' }} {{ 'World' }}: Tries to evaluate as a Python expression first.
  • {{ 'There is a trailing space' | upper }}: It's less readable.

🚫 Incorrect:

  • {{ 'Foo' | upper }}: It is evaluated as a Python expression.

Import modules

Importing modules is done using scripting. For example:

On the script tab:

from decimal import Decimal

Then under parameters:

  • {{ Decimal('0.1') }}