# FILL Populates a document template with data from variables or objects. ## Syntax ```basic result = FILL template, data FILL template, data TO output_path ``` ## Parameters | Parameter | Type | Description | |-----------|------|-------------| | `template` | String | Path to template file (Word, Excel, PDF, or text) | | `data` | Object | Key-value pairs for placeholder replacement | | `output_path` | String | Optional destination path for filled document | ## Description `FILL` replaces placeholders in document templates with actual data values. Placeholders use double curly braces like `{{name}}` or `{{company}}`. This is useful for generating personalized documents, contracts, invoices, and reports. ## Examples ### Basic Template Fill ```basic data = #{ name: "John Smith", company: "Acme Corp", date: FORMAT(TODAY(), "MMMM d, yyyy") } result = FILL "templates/contract.docx", data TALK "Document generated: " + result.path ``` ### Invoice Generation ```basic invoice_data = #{ invoice_number: "INV-2025-001", customer_name: customer.name, customer_email: customer.email, items: order_items, subtotal: subtotal, tax: tax_amount, total: total_amount, due_date: FORMAT(DATEADD("day", 30, TODAY()), "yyyy-MM-dd") } FILL "templates/invoice.docx", invoice_data TO "invoices/INV-2025-001.docx" TALK "Invoice generated and saved" ``` ### Certificate Generation ```basic certificate = #{ recipient: participant.name, course: "AI Fundamentals", completion_date: FORMAT(TODAY(), "MMMM d, yyyy"), instructor: "Dr. Sarah Johnson", certificate_id: GUID() } FILL "templates/certificate.docx", certificate TO "certificates/" + certificate.certificate_id + ".docx" ``` ### Email Template ```basic email_data = #{ first_name: user.first_name, order_id: order.id, tracking_number: shipment.tracking, delivery_date: shipment.estimated_delivery } body = FILL "templates/shipping-notification.txt", email_data SEND MAIL user.email, "Your order has shipped!", body ``` ## Supported Template Formats | Format | Extension | Placeholder Style | |--------|-----------|-------------------| | Word | `.docx` | `{{placeholder}}` | | Excel | `.xlsx` | `{{placeholder}}` | | Text | `.txt` | `{{placeholder}}` | | HTML | `.html` | `{{placeholder}}` | | Markdown | `.md` | `{{placeholder}}` | ## Return Value Returns an object containing: | Property | Description | |----------|-------------| | `path` | Path to the generated document | | `content` | Document content (for text formats) | | `size` | File size in bytes | ## Sample Conversation