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

{{ name | upper }}

Jinja2 filters transform a value inline. Common ones: upper, lower, title, trim, default("fallback").

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 when the condition is false, rather than leaving a blank line. Use this for optional paragraphs, headers, or standalone lines.

Repeating table rows

{%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. Put the {%tr for %} tag in the first cell of the row and {%tr endfor %} in the last.

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.

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