Kestra Expressions Operators, Tags, and Tests

Use this page when you need the control-flow side of Pebble rather than data transformation helpers.

Operators

Comparisons

Supported comparison operators:

  • ==
  • !=
  • <
  • >
  • <=
  • >=

Logic and boolean checks

Use:

  • and
  • or
  • not
  • is
  • contains

Examples:

{% if 2 is even and 3 is odd %}
...
{% endif %}
{% if ["apple", "pear", "banana"] contains "apple" %}
...
{% endif %}

Math and concatenation

Use:

  • +, -, *, /, %
  • ~ for string concatenation

Example:

{{ "apple" ~ "pear" ~ "banana" }}

Fallbacks and conditionals

Use:

  • ?? for null-coalescing fallbacks
  • ? : for ternary expressions

Examples:

{{ foo ?? bar ?? "default" }}
{{ foo == null ? bar : baz }}
{{ foo ?? bar ?? raise }}

For undefined vs null behavior, see the Handling null and undefined values guide.

Operator precedence

Pebble operators are evaluated in this order:

  1. .
  2. |
  3. %, /, *
  4. -, +
  5. ==, !=, >, <, >=, <=
  6. is, is not
  7. and
  8. or

Tags

Pebble tags are enclosed in {% %} and control template flow.

Most common tags

  • if
  • for
  • set
  • raw
  • filter
  • macro
  • block

Examples:

{% set header = "Welcome Page" %}
{{ header }}
{% raw %}{{ user.name }}{% endraw %}
{% for user in users %}
{{ user.name }}
{% else %}
No users found.
{% endfor %}
{% filter lower | title %}
hello world
{% endfilter %}

Tests

Tests are used with is and is not.

Common tests:

  • defined
  • empty
  • even
  • odd
  • iterable
  • json
  • map
  • null

Examples:

{% if user.email is empty %}
...
{% endif %}
{% if name is not null %}
...
{% endif %}

When to use this page

Was this page helpful?