Help Center Navigation
Word Templates

Tables, Loops & Conditional Blocks

Generate repeating table rows, bullet lists, and dynamic conditional sections with {> items }} ... {< items }} and {% if status %} ... {% endif %}.

5 min read • Guide

Many business documents require dynamic structures: invoices with varying line items, contracts with repeating signatories, or optional addendum paragraphs. Trydoku provides canonical syntax for repeating table rows, bullet loops, and conditional sections.

Repeating Table Rows: Canonical Loops

To duplicate a Word table row for each entry in a list, place the loop opening marker {> items }} in the first column of the template row and the closing marker {< items }} in the last column:

Item Name Quantity Unit Price Total
{> items }} {{ item.description }} {{ item.qty }} {{ item.price }} {{ item.total }} {< items }}

During generation, Trydoku replicates this row once for every object in your items array, preserving borders, cell padding, formulas, and text alignment.

Conditional Sections with {% if %}

Show or hide entire paragraphs, legal clauses, or table sections depending on boolean conditions or variable values:

{% if show_discount %}
Special Early-Payment Discount: A 5% discount applies if paid within 10 days.
{% endif %}

Conditional Logic Rules

  • Boolean Truthiness: If the variable is true, 1, "yes", or a non-empty string, the enclosed block will be rendered.
  • Falsy Suppression: If the variable evaluates to false, 0, null, or an empty string, the entire block (including the paragraph break) is cleanly removed from the output DOCX without leaving empty lines.
  • Strict Pairing: Every {% if condition %} must have a matching {% endif %} tag.
Canonical Syntax Reminder Trydoku uses canonical {> items }} ... {< items }} for loops and {% if status %} ... {% endif %} for conditional logic. Do not use handlebars (such as {{#each}} or {{#if}}) as those are not supported by the DOCX AST engine.

Put this into practice

Ready to take action or test what you've learned?

Test Loop Template →