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
- Create or open a
.docxfile in your word processor of choice. - Replace any variable text with
{{ field_name }}placeholders. - Upload the file in Automette. The fields are found automatically.
- Generate documents by supplying values for each field, either via the UI, a form, or the API.
- 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 and changes nothing else.
Formatting is preserved automatically
A placeholder like {{ client_name }} takes on whatever formatting you give it in Word: font, size, bold, italic and colour. The value that replaces it looks the same.
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, a common template language.
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 Word | Value supplied | Printed |
|---|---|---|
{{ name | upper }} | Acme Ltd | ACME LTD |
{{ name | lower }} | Acme Ltd | acme ltd |
{{ name | title }} | acme ltd | Acme Ltd |
{{ name | trim }} | " Acme " | Acme |
{{ notes | default("None") }} | nothing | None |
Chain them left to right: {{ name | trim | title }}.
default("...") is the one worth knowing. A field left empty leaves a gap in the document; 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 field has a value. If the tags sit on lines of their own, those lines are left behind as empty lines. 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, and 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. If a placeholder is not found, delete it and type it again in one go.
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 (such as 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.
Images
Images in the file itself, such as logos, backgrounds and signatures, are kept exactly as they are. A Word template cannot yet put a different image into each document; use a visual editor or Typst template for that.
Managing fields
After you upload the file, Automette finds the placeholders and lists them as fields. For each one you can set:
- A Label, the name people see when they fill it in.
- A Type: Text, Long text, Number, Date, Yes / No, Dropdown or List.
- For a number, Decimal places and a Thousands separator. For a date, a Date format such as
DD MMM YYYY. - Dropdown options, so people choose from a list instead of typing.
- A default value, used when no value is given.
- A hint, shown under the box on the Generate page.
These settings apply on the Generate page, in forms and through the API.
To change the document, click Download, edit it in Word, and click Replace to upload the new version. Automette tells you which fields were added or removed. Settings on fields that still exist are kept. If a field seems to be missing, click Refresh fields to scan the file again.
Bold and italic in an answer
A Word placeholder normally receives plain text. If you want whoever fills it in to be able to bold or italicise parts of what they write, give the form field the Formatted text type. The marks are carried into the Word file and the PDF, on top of the font and size your template already uses for that placeholder.
Only bold and italic travel. Pasting from Word keeps those two and drops the rest: headings, colours, fonts, sizes, lists, tables and images. A pasted paragraph cannot overrule the template's design.
Last updated on