Templating

Templates

Atuin uses MiniJinja for rendering templates, enabling flexible output customization.

Basic Syntax

  • Variables: {{ var.variable_name }}

    • Variables can be set by Script blocks

  • Filters: {{ text | upper }}, {{ list | join(", ") }}

  • Conditionals:

    {% if var.foo %}
    echo "foo is true"
    {% else %}
    echo "foo is false"
    {% endif %}
  • Loops:

    {% for remote in ["192.168.1.1", "192.168.1.2"] %}
    echo "{{ remote }}"
    {% endfor %}

Built-in Functions

  • range(n): Generates a sequence → {% for i in range(3) %}{{ i }}{% endfor %}

  • length(list): Gets list length → {{ length(users) }}

  • default(value, fallback): Uses fallback if None{{ user.name | default("Guest") }}

Document access

The template system has full access to the entire document - blocks, text, etc.

First, give a block a name. Click the pencil icon next to the default name in the top left.

Then, it can be referred to via the {{ doc.named }}map, within the template system

Last updated