Tables
Word tables are fully supported by AdviceDocs — the parser walks every cell, and placeholders, conditionals, and loops all work inside table cells. Tables get a couple of special tags {% tr ... %} and {% tc ... %} for loops and conditionals that span entire rows or columns, because plain Jinja2 blocks can’t cleanly span Word’s table-row XML structure.
Plain placeholders inside cells
Anywhere you can write a placeholder, including inside a table cell, the syntax is the same. Place {{ field_name }} directly into a cell.
Field | Value |
|---|---|
Client Name | {{ client_name }} |
Date of Birth | {{ date_of_birth }} |
Risk Profile | {{ risk_profile }} |
Total Assets | {{ total_assets }} |
Looping over rows: {% tr for %}
When you want one row per item in a collection, use the table-row loop tag. Place {% tr for item in items %} at the start of the looped row (in the first cell) and {% endtr %} at the end of the same row (in the last cell). At render time AdviceDocs duplicates the row once per item.
Asset Name | Value | Action |
|---|---|---|
{% tr for asset in assets %} | ||
{{ asset.name }} | {{ asset.value }} | {{ asset.action }} |
{% endtr %} | ||
Conditional rows: {% tr if %}
To hide an entire row when a condition is false, wrap the row with {% tr if condition %} ... {% endtr %}.
Field | Value |
|---|---|
Client | {{ client.name }} |
{% tr if has_partner %} | |
Partner | {{ partner.name }} |
{% endtr %} | |
Cell-level variants: {% tc for %} and {% tc if %}
The same idea, but for columns. Use {% tc if %} to hide a single cell (or a column when applied across all rows of a column), and {% tc for %} to repeat cells across a row.
Year | {% tc if show_returns %} Return {% endtc %} |
|---|---|
2024 | {% tc if show_returns %} 8.4% {% endtc %} |
Nested tables
A table inside a cell of another table works. The parser walks both the outer and inner tables. Placeholders, conditionals, and loops all work in nested cells. Avoid deeply nested tables in large documents — they slow Word and reduce readability.
Configuration after upload
Tables don’t have a per-table configuration. The fields inside a table are configured the same way as any other field — type inference, descriptions, condition dependencies, all from the field configuration UI.
Common pitfalls
Plain {% for %} breaks tables
{% for %} to repeat a table row. Word’s XML wraps the row in <w:tr> tags, and a plain block tag will land outside those wrappers, corrupting the table. Always use {% tr for item in items %} for row loops.Mismatched tr/tc closes
{% tr if %} closes with {% endtr %}; {% tc if %} closes with {% endtc %}. Mixing them, or using {% endif %}, raises a syntax error.Cell vs row choice
tr when a whole row should appear/disappear or repeat. Use tc when only one cell (or a column) is affected. If a column should disappear entirely, you need a tc if on every row of that column.Syntax to copy
{{ client_name }} | {{ adviser_name }} |
{% tr for product in products %} | |
{{ product.name }} | {{ product.value }} |
{% endtr %} | |
{% tr if has_partner %} | |
Partner | {{ partner.name }} |
{% endtr %} | |
{% tc if show_price %}
{{ price }}
{% endtc %}
{% tc for column in columns %}
{{ column.value }}
{% endtc %}