Document Templates for DocumentRenderV2Command
This directory contains template guides and samples for use with BankLingo's DocumentRenderV2Command.
Quick Start
- Read the Template Guide: Start with
DocumentRenderV2-Template-Guide.mdfor complete syntax reference - Choose a Template: Pick from the 8 ready-to-use templates based on your use case
- Create in Word: Design your document in Microsoft Word using the template syntax
- Upload: Use CreateDocumentTemplateDefinitiionCommand to upload to BankLingo
- Test: Test rendering with sample data
Available Templates
| Template | File Name | Use Case |
|---|---|---|
| Loan Agreement | loan-agreement-template.docx | Loan origination documents |
| Account Statement | account-statement-template.docx | Monthly account statements |
| Loan Disbursement Letter | loan-disbursement-letter.docx | Loan approval notifications |
| Certificate of Deposit | certificate-of-deposit.docx | Fixed deposit certificates |
| Collection Notice | collection-notice-template.docx | Overdue payment reminders |
| Account Opening Certificate | account-opening-certificate.docx | New account welcome letters |
| Loan Pre-Approval Letter | loan-pre-approval-letter.docx | Pre-qualification letters |
| Payment Receipt | payment-receipt-template.docx | Payment 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
- Open Microsoft Word
- Create your document layout
- Add placeholders:
{{variableName}} - Format as needed (bold, colors, fonts, etc.)
- 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
.docxfile - 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
- ✅ Use Clear Variable Names:
customerFullNamenotname - ✅ Format Data Outside Template: Format numbers/dates in context
- ✅ Test with Real Data: Use production-like data for testing
- ✅ Version Your Templates: Name changes like
template-v2.docx - ✅ Document Required Variables: List all context variables needed
- ✅ Handle Missing Data: Use conditionals for optional fields
- ✅ Keep It Simple: Complex Word features may not render perfectly
- ✅ 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