Skip to main content

Document Templates for DocumentRenderV2Command

This directory contains template guides and samples for use with BankLingo's DocumentRenderV2Command.

Quick Start

  1. Read the Template Guide: Start with DocumentRenderV2-Template-Guide.md for complete syntax reference
  2. Choose a Template: Pick from the 8 ready-to-use templates based on your use case
  3. Create in Word: Design your document in Microsoft Word using the template syntax
  4. Upload: Use CreateDocumentTemplateDefinitiionCommand to upload to BankLingo
  5. Test: Test rendering with sample data

Available Templates

TemplateFile NameUse Case
Loan Agreementloan-agreement-template.docxLoan origination documents
Account Statementaccount-statement-template.docxMonthly account statements
Loan Disbursement Letterloan-disbursement-letter.docxLoan approval notifications
Certificate of Depositcertificate-of-deposit.docxFixed deposit certificates
Collection Noticecollection-notice-template.docxOverdue payment reminders
Account Opening Certificateaccount-opening-certificate.docxNew account welcome letters
Loan Pre-Approval Letterloan-pre-approval-letter.docxPre-qualification letters
Payment Receiptpayment-receipt-template.docxPayment confirmations

Template Syntax Quick Reference

{{variableName}}                    → Simple variable
{{customer.name}} → Nested property
{{#if condition}}...{{/if}} → Conditional
{{#each array}}...{{/each}} → Loop
{{#arrayName}}...{{/arrayName}} → Table row repetition

Example Usage

// Generate a loan agreement
var doc = doCmd('DocumentRenderV2Command', {
Data: {
documentName: 'loan-agreement-template',
context: JSON.stringify({
customerName: 'John Doe',
loanAmount: 50000,
interestRate: 12.5,
tenure: 24,
monthlyPayment: 2365.22,
collateralRequired: true,
collateralDescription: 'Motor Vehicle - Toyota Corolla 2020'
}),
isPdfOutput: false
}
});

// Result contains base64-encoded document
var base64Document = doc.data;

Creating Custom Templates

Step 1: Design in Word

  1. Open Microsoft Word
  2. Create your document layout
  3. Add placeholders: {{variableName}}
  4. Format as needed (bold, colors, fonts, etc.)
  5. Save as .docx

Step 2: Upload to BankLingo

Option A: Via Command

// Read file as base64 (this would be done in your application)
var templateBase64 = '...'; // Your Word file as base64

var upload = doCmd('CreateDocumentTemplateDefinitiionCommand', {
Data: {
name: 'my-custom-template',
content: templateBase64,
description: 'My custom template for...'
}
});

Option B: Via Admin Interface

  • Navigate to Document Templates section
  • Click "Upload New Template"
  • Select your .docx file
  • Provide name and description

Step 3: Test

var test = doCmd('DocumentRenderV2Command', {
Data: {
documentName: 'my-custom-template',
context: JSON.stringify({
// Your test data matching your placeholders
}),
isPdfOutput: false
}
});

// Check result
if (test.isSuccessful) {
console.log('Template rendered successfully!');
// test.data contains base64 document
} else {
console.error('Error:', test.message);
}

Template Guidelines

Data Preparation

Always format your data before passing to the template:

// ✅ Good - Format data first
var context = {
customerName: data.firstName + ' ' + data.lastName,
loanAmount: $.format.number(data.amount, 2), // Format: 50,000.00
date: $.format.date(new Date(), 'MM/dd/yyyy'), // Format: 01/17/2026
approved: data.status === 'approved' // Boolean for conditions
};

// ❌ Bad - Raw data
var context = {
customerName: data.firstName, // Missing last name
loanAmount: data.amount, // Unformatted number
date: new Date(), // Raw date object
approved: data.status // String instead of boolean
};

Handling Arrays

For table repetition:

Row 1: {{#transactions}}
Row 2: {{date}} | {{description}} | ${{amount}}
Row 3: {{/transactions}}

For list items:

{{#each items}}
• {{this.name}}: {{this.value}}
{{/each}}

Conditional Sections

{{#if hasCollateral}}
COLLATERAL INFORMATION
Description: {{collateralDescription}}
Value: ${{collateralValue}}
{{/if}}

Best Practices

  1. ✅ Use Clear Variable Names: customerFullName not name
  2. ✅ Format Data Outside Template: Format numbers/dates in context
  3. ✅ Test with Real Data: Use production-like data for testing
  4. ✅ Version Your Templates: Name changes like template-v2.docx
  5. ✅ Document Required Variables: List all context variables needed
  6. ✅ Handle Missing Data: Use conditionals for optional fields
  7. ✅ Keep It Simple: Complex Word features may not render perfectly
  8. ✅ Use Tables for Data: Better than trying to align text

Troubleshooting

Placeholder Not Replaced

Problem: {{customerName}} appears as-is in output
Solution: Check context contains 'customerName' with correct spelling

Table Not Repeating

Problem: Only first row appears or no rows appear
Solution: Verify markers {{#arrayName}} and {{/arrayName}} are in separate rows

Conditional Not Working

Problem: {{#if condition}} section always shows/hides
Solution: Ensure condition is boolean (true/false), not string

Formatting Lost

Problem: Bold, colors, or fonts disappear
Solution: Keep formatting simple; complex styles may not preserve

Integration Examples

In Loan Origination Process

// Step 1: Approve loan
var approval = doCmd('ApproveLoanCommand', {...});

// Step 2: Generate agreement
if (approval.isSuccessful) {
var agreement = doCmd('DocumentRenderV2Command', {
Data: {
documentName: 'loan-agreement-template',
context: JSON.stringify({
...approval.loanDetails,
agreementDate: $.format.date(new Date())
}),
isPdfOutput: true
}
});

// Step 3: Store document
context.agreementDocument = agreement.data;

// Step 4: Send to customer
doCmd('SendMailCommand', {
Data: {
email: [context.customerEmail],
subject: 'Loan Agreement - Action Required',
message: 'Please review and sign your loan agreement.',
// Attach document (implementation specific)
}
});
}

In Collections Workflow

// Generate collection notice for overdue accounts
if (context.daysPastDue > 30) {
var notice = doCmd('DocumentRenderV2Command', {
Data: {
documentName: 'collection-notice-template',
context: JSON.stringify({
noticeDate: $.format.date(new Date()),
customerName: context.customerName,
accountNumber: context.accountNumber,
overdueAmount: $.format.number(context.overdueAmount, 2),
daysPastDue: context.daysPastDue,
paymentDeadline: $.format.date($.addDays(new Date(), 7))
}),
isPdfOutput: true
}
});

// Send notice
context.collectionNotice = notice.data;
}

Additional Resources

Need Help?

  • Template Issues: Check the Template Guide for syntax reference
  • Rendering Errors: Check command documentation for error codes
  • Feature Requests: Contact the BankLingo development team
  • Custom Development: Reach out for complex template requirements

Last Updated: January 2026 Version: 2.0