Automette docs
Templates

Word templates (.docx)

Word templates let you turn any .docx file into a reusable document generator. You write your template in Microsoft Word (or Google Docs, LibreOffice), mark the variable parts with {{ placeholders }}, upload the file, and Automette merges your data into it at generation time.

How it works

  1. Create or open a .docx file in your word processor of choice.
  2. Replace any variable text with {{ field_name }} placeholders.
  3. Upload the file in Automette — fields are detected automatically.
  4. Generate documents by supplying values for each field, either via the UI, a form, or the API.
  5. Download the result as DOCX or PDF.

Your fonts, colours, tables, images, headers, footers, and page layout are all preserved exactly. Automette fills in the placeholders — it does not touch anything else.


Formatting is preserved automatically

Because a placeholder like {{ client_name }} sits inside a Word run, it inherits whatever formatting that run has — font family, size, bold, italic, colour. You do not need to do anything special.

For example, if you want the client name to appear in Dancing Script italic, apply that formatting to the {{ client_name }} text in Word. When the value is filled in, the result will be Dancing Script italic.

The same applies to table cells: format the cell, put the placeholder inside it, and the generated value will look exactly like the placeholder text did.


Placeholder syntax

Word templates use Jinja2 syntax — the same template language used by tools like Ansible, Cookiecutter, and Django.

Single value

{{ client_name }}

Replaced with the field value at generation time.

Filters

A filter transforms the value on its way into the document, so whoever supplies the data does not have to format it. Read | as "then".

Written in WordValue suppliedPrinted
{{ name | upper }}Acme LtdACME LTD
{{ name | lower }}Acme Ltdacme ltd
{{ name | title }}acme ltdAcme Ltd
{{ name | trim }}" Acme "Acme
{{ notes | default("None") }}nothingNone

Chain them left to right: {{ name | trim | title }}.

default("...") is the one worth knowing. A Word template prints exactly what it is given, so a field nobody filled in leaves a blank gap — default puts something there instead.

Conditional content

{% if balance_due %}
  Amount due: {{ balance_due }}
{% endif %}

Content between {% if %} and {% endif %} is included only when the condition is truthy. Note: the {% if %} and {% endif %} tags each occupy their own paragraph — they are removed from the output, but if they are on their own line, that line becomes an empty paragraph. Use {%p if %} to avoid this.

Conditional paragraph (no blank line)

{%p if show_notes %}
This is a note.
{%p endif %}

The {%p prefix tells Automette to remove the entire paragraph element, rather than leaving a blank line. Use this for optional paragraphs, headers, or standalone lines.

Each {%p tag needs its own paragraph — its own line in Word, made with Enter rather than Shift+Enter. Putting the opening and closing tags in a single paragraph fails at generation with unknown tag 'endif', because the first tag removes the paragraph the second one was in.

Repeating table rows

Use three rows — the loop opener, the row to repeat, the loop closer:

| {%tr for item in line_items %} |                     |                  |
| {{ item.description }}         | {{ item.quantity }} | {{ item.total }} |
| {%tr endfor %}                 |                     |                  |

The {%tr prefix repeats the entire table row for each item in the list, and removes the row its own tag sits in.

The opening and closing tags each need their own row. Both in one row fails at generation with unknown tag 'endfor', for the same reason as {%p: the opening tag removes the row the closing tag was in. Put {%tr for %} in the first cell of a row of its own, the content in the next row, and {%tr endfor %} in the first cell of a third row.

Conditional value in a cell

{{ "✓" if rating == "Excellent" else "" }}

Useful for checkbox-style columns in a table. The expression stays entirely within one run, so the font and size of the character will match whatever formatting is on the cell.


Tips

Keep placeholders in a single run. Word sometimes splits text across multiple runs when you edit it (particularly when autocorrect, spell-check, or track changes is on). If a placeholder like {{ client_name }} gets split into {{ clie + nt_name }}, it will not be recognised. To check: turn on "Show Formatting Marks" in Word and inspect the paragraph XML, or simply delete the placeholder and retype it.

A block tag never shares its paragraph or row with its closer. {%p if %} and {%p endif %} need one paragraph each; {%tr for %} and {%tr endfor %} need one table row each. The prefixed forms work by deleting the paragraph or row they sit in, so a compact one-line version deletes its own closing tag. Nothing catches this at upload — the file uploads, the fields are detected, and it fails only when you generate a document.

Use {%p if %} for optional sections. {% if %} leaves an empty line; {%p if %} removes the paragraph entirely. For sections that should appear only sometimes (e.g. a "Payment Terms" paragraph), {%p if %} gives a cleaner result.

Table row loops require the {%tr prefix. A standard {% for %} inside a table row will not repeat the row — it will only repeat the content within the current cell. Always use {%tr for %} when the loop should repeat full rows.

Jinja2 filters apply to any value. You can chain them: {{ name | trim | title }}. See the Jinja2 filter reference for the full list.


Image fields

Image insertion in Word templates is coming soon. Today, images in the template itself (logos, backgrounds, decorative graphics) are preserved as-is. Variable images — where each generated document gets a different image — are not yet supported.

This is planned as a future update. When it ships, you will be able to define an image field (e.g. {{ signature }}) and supply an image URL or file per generation. Follow the changelog for updates.


Managing fields

After you upload a .docx file, Automette scans it for placeholders and lists them as fields. For each field you can:

  • Set a label — the human-readable name shown in forms and the UI
  • Change the type — text, number, date, boolean, or dropdown
  • Add dropdown options — users see a select list instead of a free-text input
  • Add a hint — helper text shown below the field

Fields and their settings carry through to the Generate page, custom forms, and the API.

If you update the template file, click Refresh fields to re-scan for any added or removed placeholders. Any customisations you've made to existing fields are preserved.

Last updated on

On this page