Word Template Table Syntax - Critical Fix Guide
THE PROBLEM
When you see this error:
Error rendering document from Base64: Unclosed section '{{#transactions}}'.
This means your table markers are not properly placed in the Word document.
THE SOLUTION
For repeating table rows, you MUST follow this exact structure:
✅ CORRECT Way (4 Rows Required):
┌─────────────────┬─────────────────┬─────────────────┐
│ Row 1: HEADER │ Column 2 Header │ Column 3 Header │ ← Header row
├─────────────────┼─────────────────┼─────────────────┤
│ {{#transactions}}│ │ │ ← Opening marker (ONLY in first cell)
├─────────────────┼─────────────────┼─────────────────┤
│ {{date}} │ {{description}} │ {{amount}} │ ← Template row with all placeholders
├─────────────────┼─────────────────┼─────────────────┤
│ {{/transactions}}│ │ │ ← Closing marker (ONLY in first cell)
└─────────────────┴─────────────────┴─────────────────┘
❌ WRONG Ways:
Wrong 1: Markers in same row
┌─────────────────┬─────────────────┬─────────────────┐
│ {{#transactions}} {{date}} │ {{amount}} │ ← WRONG! Don't mix
Wrong 2: Markers in multiple cells
┌─────────────────┬─────────────────┬─────────────────┐
│ {{#transactions}}│ {{#transactions}}│ │ ← WRONG! Only first cell
Wrong 3: Missing closing marker
┌─────────────────┬─────────────────┬─────────────────┐
│ {{#transactions}}│ │ │
├─────────────────┼─────────────────┼─────────────────┤
│ {{date}} │ {{amount}} │ │
└─────────────────┴─────────────────┴─────────────────┘
← WRONG! No closing marker
STEP-BY-STEP FIX
For Account Statement Template:
-
Open the Word template file
-
Find the transactions table
-
Verify it has exactly 4 rows:
- Row 1: Headers (Date, Transaction ID, Description, etc.)
- Row 2:
{{#transactions}}(ONLY in first cell, other cells empty) - Row 3:
{{date}},{{transactionId}},{{description}}, etc. - Row 4:
{{/transactions}}(ONLY in first cell, other cells empty)
-
If wrong, fix it:
- Delete all rows except header
- Insert 3 new rows below header
- Row 2: Type
{{#transactions}}in first cell only - Row 3: Type all your placeholders:
{{date}},{{transactionId}}, etc. - Row 4: Type
{{/transactions}}in first cell only
For Payment Schedule Template:
Same 4-row structure:
Row 1: Payment No. | Due Date | Principal | Interest | Total | Balance
Row 2: {{#schedule}} (first cell only)
Row 3: {{paymentNumber}} | {{dueDate}} | ${{principal}} | ${{interest}} | ${{totalPayment}} | ${{remainingBalance}}
Row 4: {{/schedule}} (first cell only)
For Invoice Template:
Same 4-row structure:
Row 1: Description | Quantity | Unit Price | Tax | Amount
Row 2: {{#lineItems}} (first cell only)
Row 3: {{description}} | {{quantity}} | ${{unitPrice}} | ${{tax}} | ${{amount}}
Row 4: {{/lineItems}} (first cell only)
VISUAL GUIDE
When you look at your Word table, you should see:
╔═══════════════╦═══════════════╦═══════════════╗
║ Date ║ Description ║ Amount ║ ← Row 1: Headers (keep as-is)
╠═══════════════╬═══════════════╬═══════════════╣
║ {{#transactions}} ║ ║ ║ ← Row 2: Opening tag ONLY
╠═══════════════╬═══════════════╬═══════════════╣
║ {{date}} ║ {{description}}║ {{amount}} ║ ← Row 3: Your data placeholders
╠═══════════════╬═══════════════╬═══════════════╣
║ {{/transactions}} ║ ║ ║ ← Row 4: Closing tag ONLY
╚═══════════════╩═══════════════╩═══════════════╝
TESTING
After fixing, test with this command:
var testData = {
transactions: [
{ date: "Jan 1", description: "Test 1", amount: "100.00" },
{ date: "Jan 2", description: "Test 2", amount: "200.00" }
]
};
var result = doCmd('DocumentRenderV2Command', {
Data: {
documentName: 'your-template-name',
context: JSON.stringify(testData),
isPdfOutput: false
}
});
console.log('Success:', result.isSuccessful);
console.log('Message:', result.message);
COMMON MISTAKES TO AVOID
- ❌ Putting
{{#transactions}}and{{/transactions}}in the same row - ❌ Putting markers in cells other than the first column
- ❌ Having text before/after the marker in the same cell (e.g., "Start:
{{#transactions}}") - ❌ Forgetting the closing
{{/transactions}}tag - ❌ Having only 3 rows (you need 4: header + open + template + close)
- ❌ Typos in marker names (e.g.,
{{#transaction}}vs{{#transactions}})
QUICK CHECKLIST
- My table has at least 4 rows
- Row 1 is my header row
- Row 2 has
{{#arrayName}}in ONLY the first cell - Row 3 has all my placeholder variables like
{{fieldName}} - Row 4 has
{{/arrayName}}in ONLY the first cell - Opening and closing markers use the EXACT same name
- There are no extra spaces in the markers
IF STILL HAVING ISSUES
- Check for extra spaces:
{{ #transactions }}(WRONG) vs{{#transactions}}(CORRECT) - Check marker names match:
{{#transactions}}must close with{{/transactions}}(not{{/transaction}}) - Delete and recreate the table - sometimes Word formatting gets corrupted
- Save as .docx (not .doc) - the command requires .docx format
FOR NESTED ARRAYS
If you have nested data like credit card transactions by category:
{
"categories": [
{
"categoryName": "Dining",
"transactions": [
{ "date": "Jan 1", "merchant": "Restaurant", "amount": "50.00" }
]
}
]
}
You'll need nested tables:
Row 1: Category | Details
Row 2: {{#categories}} (in first cell only)
Row 3: {{categoryName}} | [Nested table with {{#transactions}}...{{/transactions}}]
Row 4: {{/categories}} (in first cell only)
SUMMARY
Remember: Opening marker → Template row → Closing marker = 3 SEPARATE ROWS (plus your header = 4 rows total)
The template engine reads the Word document and needs these markers in separate rows to know where to start repeating, what to repeat, and where to stop.