# Response Examples Source: https://docs.fileloom.io/api-reference/examples Sample API responses for various scenarios including success, errors, and edge cases. This page provides complete response examples for different API scenarios. ## Successful Generation ### Raw HTML Generation **Request:** ```json theme={null} { "htmlContent": "
This is a test PDF.
" } ``` **Response:** ```json theme={null} { "success": true, "requestId": "req_1734012345678_a1b2c3d4e", "data": { "fileId": "file_1734012345678_x9y8z7w6", "url": "https://storage.googleapis.com/fileloom-prod/workspaces/ws_abc123/pdfs/2024/12/document-1734012345678.pdf", "signedUrl": "https://storage.googleapis.com/fileloom-prod/workspaces/ws_abc123/pdfs/2024/12/document-1734012345678.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=...", "filename": "document.pdf", "size": 8234, "expiresAt": "2024-12-16T10:30:00.000Z", "storageProvider": "firebase", "processingTimeMs": 623, "generationMethod": "html", "templateUsed": null }, "usage": { "remaining": 9847, "quotaUsed": 153, "quotaLimit": 10000 } } ``` ### Template Generation **Request:** ```json theme={null} { "templateId": "tpl_invoice_v2", "templateData": { "invoiceNumber": "INV-2024-0042", "customerName": "Acme Corp", "total": 1250.00 } } ``` **Response:** ```json theme={null} { "success": true, "requestId": "req_1734012398765_f5g6h7i8", "data": { "fileId": "file_1734012398765_m3n4o5p6", "url": "https://storage.googleapis.com/fileloom-prod/workspaces/ws_abc123/pdfs/2024/12/Invoice-INV-2024-0042-1734012398765.pdf", "signedUrl": "https://storage.googleapis.com/fileloom-prod/workspaces/ws_abc123/pdfs/2024/12/Invoice-INV-2024-0042-1734012398765.pdf?X-Goog-Algorithm=...", "filename": "Invoice-INV-2024-0042.pdf", "size": 45678, "expiresAt": "2024-12-16T10:33:18.000Z", "storageProvider": "firebase", "processingTimeMs": 1247, "generationMethod": "template", "templateUsed": { "id": "tpl_invoice_v2", "name": "Professional Invoice" } }, "usage": { "remaining": 9846, "quotaUsed": 154, "quotaLimit": 10000 } } ``` ### With External Storage **Response (storage mode: "both"):** ```json theme={null} { "success": true, "requestId": "req_1734012456789_j1k2l3m4", "data": { "fileId": "file_1734012456789_q7r8s9t0", "url": "https://storage.googleapis.com/fileloom-prod/workspaces/ws_abc123/pdfs/2024/12/report-1734012456789.pdf", "signedUrl": "https://storage.googleapis.com/fileloom-prod/...", "filename": "report.pdf", "size": 128456, "expiresAt": "2024-12-16T10:40:56.000Z", "storageProvider": "firebase", "processingTimeMs": 2341, "generationMethod": "template", "templateUsed": { "id": "tpl_report_monthly", "name": "Monthly Report" }, "externalCopies": [ { "provider": "s3", "name": "Production Backup", "url": "https://acme-docs.s3.us-west-2.amazonaws.com/reports/2024/12/report-1734012456789.pdf", "expiresAt": "2024-12-22T10:40:56.000Z" } ] }, "usage": { "remaining": 9845, "quotaUsed": 155, "quotaLimit": 10000 } } ``` ### With Warnings When external storage partially fails: ```json theme={null} { "success": true, "requestId": "req_1734012567890_n5o6p7q8", "data": { "fileId": "file_1734012567890_u1v2w3x4", "url": "https://storage.googleapis.com/fileloom-prod/...", "signedUrl": "https://storage.googleapis.com/fileloom-prod/...", "filename": "document.pdf", "size": 23456, "storageProvider": "firebase", "processingTimeMs": 1567, "generationMethod": "html", "templateUsed": null }, "warnings": [ { "provider": "s3", "name": "Backup Storage", "error": "Access denied: invalid credentials" } ], "usage": { "remaining": 9844, "quotaUsed": 156, "quotaLimit": 10000 } } ``` ## Error Responses ### Validation Error **Request (missing required field):** ```json theme={null} { "templateData": { "name": "Test" } } ``` **Response (400):** ```json theme={null} { "error": { "code": "VALIDATION_ERROR", "message": "Input validation failed", "details": [ "Either htmlContent or templateId is required" ], "requestId": "req_1734012678901_r9s0t1u2", "timestamp": "2024-12-15T10:51:18.901Z" } } ``` ### Invalid API Key **Response (401):** ```json theme={null} { "error": { "code": "INVALID_API_KEY", "message": "Invalid API key", "requestId": "req_1734012789012_v3w4x5y6", "timestamp": "2024-12-15T10:53:09.012Z" } } ``` ### Template Not Found **Request:** ```json theme={null} { "templateId": "tpl_nonexistent", "templateData": {} } ``` **Response (404):** ```json theme={null} { "error": { "code": "TEMPLATE_NOT_FOUND", "message": "Template not found", "requestId": "req_1734012890123_z7a8b9c0", "timestamp": "2024-12-15T10:54:50.123Z" } } ``` ### Template Compilation Error **Request (invalid Handlebars syntax):** ```json theme={null} { "htmlContent": "Amount: {{currency amount \"USD\"}}
", "templateData": { "number": "INV-001", "amount": 299.99 } }' ``` ### Full Options ```bash theme={null} curl -X POST https://api.fileloom.io/v1/pdf/generate \ -H "X-API-Key: fl_your_api_key" \ -H "Content-Type: application/json" \ -d '{ "htmlContent": "Content here
", "filename": "quarterly-report", "options": { "format": "Letter", "orientation": "landscape", "margin": { "top": 20, "right": 15, "bottom": 20, "left": 15 }, "printBackground": true, "header": { "enabled": true, "height": 15, "content": "
## Profile Settings
Update your personal information:
| Setting | Description |
| ---------------- | ------------------------------------------------ |
| **Display Name** | Your name shown in the dashboard |
| **Email** | Account email (used for login and notifications) |
| **Photo** | Profile picture (from Google/GitHub or uploaded) |
### Connected Accounts
If you signed up with Google or GitHub, your authentication is managed by that provider. To change your password, use your Google or GitHub account settings.
## Deleting Your Account
## API Keys List
| Column | Description |
| -------------- | --------------------------------- |
| **Name** | Friendly name for the key |
| **Key Prefix** | First 8 characters (fl\_xxxxxxxx) |
| **Created** | When the key was created |
| **Last Used** | Most recent API call |
| **Status** | Active or Revoked |
## Creating an API Key
## Current Plan
The billing page shows your current subscription:
* **Plan name** — Free, Starter, Growth, Scale, etc.
* **Billing period** — Monthly or Annual
* **Next billing date** — When your subscription renews
* **Monthly quota** — PDFs included in your plan
## Changing Plans
### Upgrading
## Files List
| Column | Description |
| ------------ | ------------------------------ |
| **Filename** | PDF filename |
| **Template** | Template used (or "Raw HTML") |
| **Size** | File size in KB/MB |
| **Created** | Generation timestamp |
| **Status** | Generated, Expired, or Deleted |
| **Actions** | Download, view, delete |
## Filtering Files
Filter files by various criteria:
* **Date range** — Filter by creation date
## File Details
Click a file to view its details:
| Field | Description |
| -------------- | ----------------------------- |
| **File ID** | Unique identifier (file\_xxx) |
| **Public URL** | Permanent download link |
| **Signed URL** | Temporary secure link |
| **Template** | Template used for generation |
| **Size** | File size |
| **Created** | Timestamp |
| **Expires** | When file will be deleted |
| **Downloads** | Number of times downloaded |
## Downloading Files
Multiple ways to download:
1. **Quick download** — Click the download icon in the files list
2. **Detail panel** — Click "Download" in the file details
3. **Public URL** — Copy and open the permanent URL
4. **API** — Use the URL returned from PDF generation
## File Retention
Files are automatically deleted based on your plan:
| Plan | Retention |
| ---------------- | --------- |
| Free | 7 days |
| Starter | 30 days |
| Growth | 90 days |
| Scale | 180 days |
| Scale Business | 365 days |
| Scale Enterprise | 365 days |
## Signing In
Fileloom supports multiple authentication methods:
* **Email & Password** — Create an account with your email
* **Google** — Sign in with your Google account
* **GitHub** — Sign in with your GitHub account
* **SSO** — Available on Scale Enterprise plans
## Members List
| Column | Description |
| ---------- | ------------------------------ |
| **Member** | Name and email |
| **Role** | Owner, Editor, or Viewer |
| **Joined** | When they joined the workspace |
| **Status** | Active or Pending invitation |
## Inviting Members
## Creating a Template
## Switching Workspaces
Use the workspace dropdown at the top of the sidebar to switch between workspaces. The dropdown shows:
* Workspace name
* Your role (Owner, Editor, Viewer)
* Settings icon for quick access
## Creating a Workspace
Customer: {{customer.name}}
Total: {{currency total "USD"}}
Generated with Fileloom!
" }' ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.fileloom.io/v1/pdf/generate', { method: 'POST', headers: { 'X-API-Key': 'fl_your_api_key', 'Content-Type': 'application/json' }, body: JSON.stringify({ htmlContent: 'Generated with Fileloom!
' }) }); const result = await response.json(); console.log(result.data.url); // URL to your PDF ``` ```python Python theme={null} import requests response = requests.post( 'https://api.fileloom.io/v1/pdf/generate', headers={ 'X-API-Key': 'fl_your_api_key', 'Content-Type': 'application/json' }, json={ 'htmlContent': 'Generated with Fileloom!
' } ) result = response.json() print(result['data']['url']) # URL to your PDF ``` ```typescript TypeScript theme={null} interface FileloomResponse { success: boolean; data: { fileId: string; url: string; filename: string; size: number; processingTimeMs: number; }; } const response = await fetch('https://api.fileloom.io/v1/pdf/generate', { method: 'POST', headers: { 'X-API-Key': 'fl_your_api_key', 'Content-Type': 'application/json' }, body: JSON.stringify({ htmlContent: 'Generated with Fileloom!
' }) }); const result: FileloomResponse = await response.json(); console.log(result.data.url); ``` ```php PHP theme={null} $ch = curl_init('https://api.fileloom.io/v1/pdf/generate'); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'X-API-Key: fl_your_api_key', 'Content-Type: application/json' ], CURLOPT_POSTFIELDS => json_encode([ 'htmlContent' => 'Generated with Fileloom!
' ]) ]); $response = curl_exec($ch); $result = json_decode($response, true); echo $result['data']['url']; // URL to your PDF ``` ```go Go theme={null} package main import ( "bytes" "encoding/json" "fmt" "net/http" ) func main() { payload := map[string]string{ "htmlContent": "Generated with Fileloom!
", } body, _ := json.Marshal(payload) req, _ := http.NewRequest("POST", "https://api.fileloom.io/v1/pdf/generate", bytes.NewBuffer(body)) req.Header.Set("X-API-Key", "fl_your_api_key") req.Header.Set("Content-Type", "application/json") client := &http.Client{} resp, _ := client.Do(req) defer resp.Body.Close() var result map[string]interface{} json.NewDecoder(resp.Body).Decode(&result) data := result["data"].(map[string]interface{}) fmt.Println(data["url"]) } ```Amount: {{currency amount \"USD\"}}
Due: {{formatDate dueDate \"MMMM D, YYYY\"}}
", "templateData": { "invoiceNumber": "INV-2024-001", "amount": 299.99, "dueDate": "2024-12-31" } }' ``` ```javascript JavaScript theme={null} const response = await fetch('https://api.fileloom.io/v1/pdf/generate', { method: 'POST', headers: { 'X-API-Key': 'fl_your_api_key', 'Content-Type': 'application/json' }, body: JSON.stringify({ htmlContent: 'Amount: {{currency amount "USD"}}
Due: {{formatDate dueDate "MMMM D, YYYY"}}
', templateData: { invoiceNumber: 'INV-2024-001', amount: 299.99, dueDate: '2024-12-31' } }) }); const result = await response.json(); console.log(result.data.url); ``` ```python Python theme={null} import requests response = requests.post( 'https://api.fileloom.io/v1/pdf/generate', headers={ 'X-API-Key': 'fl_your_api_key', 'Content-Type': 'application/json' }, json={ 'htmlContent': 'Amount: {{currency amount "USD"}}
Due: {{formatDate dueDate "MMMM D, YYYY"}}
', 'templateData': { 'invoiceNumber': 'INV-2024-001', 'amount': 299.99, 'dueDate': '2024-12-31' } } ) result = response.json() print(result['data']['url']) ```Featured: {{first featuredProducts}}
``` ## last Returns the last element of an array. ```handlebars theme={null} {{last items}} ``` **Example:** ```handlebars theme={null} {{! items = ["Apple", "Banana", "Cherry"] }} {{last items}} ``` **Output:** `Cherry` ```handlebars theme={null}Most recent order: #{{last orderNumbers}}
``` ## at Returns the element at a specific index (zero-based). ```handlebars theme={null} {{at items 1}} ``` | Argument | Type | Default | Description | | -------- | ------ | -------- | ----------------- | | `array` | array | required | Source array | | `index` | number | 0 | Index to retrieve | **Example:** ```handlebars theme={null} {{! items = ["Apple", "Banana", "Cherry"] }} {{at items 1}} ``` **Output:** `Banana` ## join Joins array elements into a string with a separator. ```handlebars theme={null} {{join items ", "}} ``` | Argument | Type | Default | Description | | ----------- | ------ | -------- | -------------------------- | | `array` | array | required | Array to join | | `separator` | string | ", " | Separator between elements | **Examples:** ```handlebars theme={null} {{! tags = ["javascript", "nodejs", "api"] }} {{join tags ", "}} ``` **Output:** `javascript, nodejs, api` ```handlebars theme={null} {{join tags " | "}} ``` **Output:** `javascript | nodejs | api` ```handlebars theme={null}Categories: {{join categories ", "}}
Phone: {{join phoneParts "-"}}
``` ## length Returns the length of an array, string, or object. ```handlebars theme={null} {{length items}} ``` **Examples:** ```handlebars theme={null} {{! items = ["A", "B", "C"] }} {{length items}} ``` **Output:** `3` ```handlebars theme={null}{{length items}} items in cart
{{length description}} characters
``` ## contains Returns `true` if the array contains a value. ```handlebars theme={null} {{contains array value}} ``` **Example:** ```handlebars theme={null} {{! roles = ["admin", "editor"] }} {{#if (contains roles "admin")}} Admin {{/if}} ``` ## sum Calculates the sum of array values or a specific property. ```handlebars theme={null} {{sum numbers}} {{sum items "price"}} ``` | Argument | Type | Default | Description | | ---------- | ------ | -------- | ---------------------------------------- | | `array` | array | required | Array to sum | | `property` | string | null | Property name to sum (for object arrays) | **Examples:** ```handlebars theme={null} {{! numbers = [10, 20, 30] }} {{sum numbers}} ``` **Output:** `60` ```handlebars theme={null} {{! items = [{price: 10}, {price: 20}, {price: 30}] }} {{sum items "price"}} ``` **Output:** `60` ```handlebars theme={null}Total: {{currency (sum items "price") "USD"}}
Total Quantity: {{sum items "quantity"}}
``` ## average Calculates the average of array values or a specific property. ```handlebars theme={null} {{average numbers}} {{average items "rating"}} ``` | Argument | Type | Default | Description | | ---------- | ------ | -------- | --------------------------------- | | `array` | array | required | Array to average | | `property` | string | null | Property name (for object arrays) | **Examples:** ```handlebars theme={null} {{! scores = [85, 90, 78, 92] }} {{average scores}} ``` **Output:** `86.25` ```handlebars theme={null}Average Rating: {{round (average reviews "rating") 1}} / 5
``` ## max Returns the maximum value in an array. ```handlebars theme={null} {{max numbers}} {{max items "price"}} ``` | Argument | Type | Default | Description | | ---------- | ------ | -------- | --------------------------------- | | `array` | array | required | Array to search | | `property` | string | null | Property name (for object arrays) | **Examples:** ```handlebars theme={null} {{! prices = [29.99, 49.99, 19.99] }} {{max prices}} ``` **Output:** `49.99` ```handlebars theme={null}Highest Price: {{currency (max products "price") "USD"}}
``` ## min Returns the minimum value in an array. ```handlebars theme={null} {{min numbers}} {{min items "price"}} ``` | Argument | Type | Default | Description | | ---------- | ------ | -------- | --------------------------------- | | `array` | array | required | Array to search | | `property` | string | null | Property name (for object arrays) | **Examples:** ```handlebars theme={null} {{! prices = [29.99, 49.99, 19.99] }} {{min prices}} ``` **Output:** `19.99` ```handlebars theme={null}Starting at {{currency (min products "price") "USD"}}
``` ## Practical Examples ### Order Summary ```handlebars theme={null}Items: {{length items}}
Total Quantity: {{sum items "quantity"}}
Subtotal: {{currency (sum items "total") "USD"}}
{{currency (min variants "price") "USD"}} - {{currency (max variants "price") "USD"}}
Total Sales: {{currency (sum orders "total") "USD"}}
Average Order: {{currency (average orders "total") "USD"}}
Largest Order: {{currency (max orders "total") "USD"}}
Smallest Order: {{currency (min orders "total") "USD"}}
| {{this.description}} | {{this.quantity}} | {{currency this.unitPrice "USD"}} | {{currency (multiply this.quantity this.unitPrice) "USD"}} |
| Total Items | {{sum lineItems "quantity"}} | ||
| Subtotal | {{currency (sum lineItems "total") "USD"}} | ||
{{#if (eq (length authors) 1)}} Author: {{first authors}} {{else if (eq (length authors) 2)}} Authors: {{at authors 0}} and {{at authors 1}} {{else}} Authors: {{at authors 0}}, {{at authors 1}}, and {{subtract (length authors) 2}} others {{/if}}
``` # Business Helpers Source: https://docs.fileloom.io/helpers/business Simplify business calculations with tax, discount, invoice number, and due date helpers. Business helpers provide common calculations for invoices, receipts, and financial documents. ## calculateTax Calculates tax amount based on a tax rate percentage. ```handlebars theme={null} {{calculateTax amount taxRate}} ``` | Argument | Type | Description | | --------- | ------ | ------------------------------------------- | | `amount` | number | Base amount | | `taxRate` | number | Tax rate as percentage (e.g., 8.5 for 8.5%) | **Examples:** ```handlebars theme={null} {{calculateTax 100 8.5}} ``` **Output:** `8.50` ```handlebars theme={null}Subtotal: {{currency subtotal "USD"}}
Tax ({{taxRate}}%): {{currency (calculateTax subtotal taxRate) "USD"}}
``` ## calculateDiscount Calculates discount amount based on a discount percentage. ```handlebars theme={null} {{calculateDiscount amount discountPercent}} ``` | Argument | Type | Description | | ----------------- | ------ | ----------------------------------------- | | `amount` | number | Original amount | | `discountPercent` | number | Discount as percentage (e.g., 20 for 20%) | **Examples:** ```handlebars theme={null} {{calculateDiscount 100 20}} ``` **Output:** `20.00` ```handlebars theme={null}Original: {{currency originalPrice "USD"}}
Discount ({{discountPercent}}%): -{{currency (calculateDiscount originalPrice discountPercent) "USD"}}
Final: {{currency (subtract originalPrice (calculateDiscount originalPrice discountPercent)) "USD"}}
``` ## netAmount Calculates net amount after tax and discount. ```handlebars theme={null} {{netAmount amount taxRate discountPercent}} ``` | Argument | Type | Default | Description | | ----------------- | ------ | -------- | ------------------- | | `amount` | number | required | Original amount | | `taxRate` | number | 0 | Tax rate percentage | | `discountPercent` | number | 0 | Discount percentage | **Calculation:** `(amount - discount) + tax on discounted amount` **Examples:** ```handlebars theme={null} {{netAmount 100 10 20}} ``` Calculation: * Original: \$100 * Discount (20%): -\$20 * Subtotal: \$80 * Tax (10% of $80): +$8 * **Net: \$88.00** ```handlebars theme={null}Grand Total: {{currency (netAmount subtotal taxRate discountPercent) "USD"}}
``` ## invoiceNumber Generates a formatted invoice number. ```handlebars theme={null} {{invoiceNumber}} {{invoiceNumber "INV" 42 6}} ``` | Argument | Type | Default | Description | | ----------- | ------ | ------- | ------------------------- | | `prefix` | string | "INV" | Prefix for the invoice | | `number` | number | 1 | Sequential number | | `padLength` | number | 6 | Padding length for number | **Format:** `PREFIX-YYYYMM-NUMBER` **Examples:** ```handlebars theme={null} {{invoiceNumber}} ``` **Output:** `INV-202412-000001` ```handlebars theme={null} {{invoiceNumber "INV" 42 6}} ``` **Output:** `INV-202412-000042` ```handlebars theme={null} {{invoiceNumber "REC" 1234 8}} ``` **Output:** `REC-202412-00001234` ```handlebars theme={null} {{invoiceNumber "PO" orderNumber 5}} ``` ## dueDate Calculates a due date by adding days to an invoice date. ```handlebars theme={null} {{dueDate invoiceDate 30}} ``` | Argument | Type | Default | Description | | ------------- | ----------- | ------- | -------------- | | `invoiceDate` | string/Date | now | Starting date | | `terms` | number | 30 | Days until due | **Examples:** ```handlebars theme={null} {{dueDate "2024-12-15" 30}} ``` **Output:** `2025-01-14` ```handlebars theme={null}Invoice Date: {{formatDate invoiceDate "MMM D, YYYY"}}
Payment Terms: Net {{paymentTerms}}
Due Date: {{formatDate (dueDate invoiceDate paymentTerms) "MMM D, YYYY"}}
``` ## Practical Examples ### Complete Invoice Calculations ```handlebars theme={null}| Description | Qty | Unit Price | Amount |
|---|---|---|---|
| {{this.description}} | {{this.quantity}} | {{currency this.unitPrice "USD"}} | {{currency (multiply this.quantity this.unitPrice) "USD"}} |
{{company.address}}
| Invoice #: | {{invoiceNumber "INV" invoiceSequence 6}} |
| Date: | {{formatDate invoiceDate "MMMM D, YYYY"}} |
| Due Date: | {{formatDate (dueDate invoiceDate paymentTerms) "MMMM D, YYYY"}} |
Payment is due within {{paymentTerms}} days of invoice date.
Invoice Date: {{formatDate invoiceDate "MMM D, YYYY"}}
Due Date: {{formatDate (dueDate invoiceDate paymentTerms) "MMM D, YYYY"}}
This invoice is {{daysBetween (dueDate invoiceDate paymentTerms)}} days overdue.
{{/if}}Receipt #: {{invoiceNumber "REC" receiptNumber 8}}
Date: {{formatDate transactionDate "MMM D, YYYY"}}
Large order discount applied!
{{/if}} ``` ## lt (Less Than) Returns `true` if the first value is less than the second. ```handlebars theme={null} {{lt 5 10}} ``` **Output:** `true` ```handlebars theme={null} {{#if (lt stock 10)}} Low Stock {{/if}} ``` ## gte (Greater Than or Equal) Returns `true` if the first value is greater than or equal to the second. ```handlebars theme={null} {{gte 10 10}} ``` **Output:** `true` ```handlebars theme={null} {{#if (gte quantity minimumOrder)}} {{else}}Minimum order: {{minimumOrder}} units
{{/if}} ``` ## lte (Less Than or Equal) Returns `true` if the first value is less than or equal to the second. ```handlebars theme={null} {{lte 5 10}} ``` **Output:** `true` ```handlebars theme={null} {{#if (lte balance 0)}} Payment Required {{/if}} ``` ## eq (Equal) Returns `true` if both values are equal (loose equality). ```handlebars theme={null} {{eq status "active"}} ``` **Output:** `true` (if status is "active") ```handlebars theme={null} {{#if (eq status "active")}} Active {{else if (eq status "pending")}} Pending {{else if (eq status "inactive")}} Inactive {{/if}} ``` ## neq (Not Equal) Returns `true` if values are not equal. ```handlebars theme={null} {{neq status "deleted"}} ``` **Output:** `true` (if status is not "deleted") ```handlebars theme={null} {{#if (neq status "cancelled")}} {{/if}} ``` ## Combining Comparisons Use with logical helpers for complex conditions: ```handlebars theme={null} {{! Between range: 10 <= value <= 100 }} {{#if (and (gte value 10) (lte value 100))}}Value is in range
{{/if}} {{! Either condition }} {{#if (or (eq status "active") (eq status "pending"))}}Order is being processed
{{/if}} {{! Complex condition }} {{#if (and (gt quantity 0) (eq inStock true) (neq status "discontinued"))}} {{/if}} ``` ## Practical Examples ### Pricing Tiers ```handlebars theme={null} {{#if (gte quantity 100)}}Bulk pricing: {{currency bulkPrice "USD"}}/unit
{{else if (gte quantity 50)}}Volume pricing: {{currency volumePrice "USD"}}/unit
{{else}}Standard pricing: {{currency standardPrice "USD"}}/unit
{{/if}} ``` ### Stock Status ```handlebars theme={null} {{#if (eq stock 0)}} Out of Stock {{else if (lt stock 10)}} Only {{stock}} left! {{else}} In Stock {{/if}} ``` ### Order Status Badge ```handlebars theme={null} {{titleCase status}} ``` ### Discount Eligibility ```handlebars theme={null} {{#if (and (gte subtotal 100) (lt discountApplied 1))}}You qualify for free shipping!
Invoice Date: {{formatDate invoiceDate "MMM D, YYYY"}}
Due Date: {{formatDate (addDays invoiceDate 30) "MMM D, YYYY"}}
``` ## daysBetween Calculates the number of days between two dates. ```handlebars theme={null} {{daysBetween startDate endDate}} {{daysBetween startDate}} ``` | Argument | Type | Default | Description | | -------- | ----------- | -------- | ----------- | | `date1` | string/Date | required | First date | | `date2` | string/Date | now | Second date | **Examples:** ```handlebars theme={null} {{daysBetween "2024-12-01" "2024-12-15"}} ``` **Output:** `14` ```handlebars theme={null} {{! Days until due date }} {{daysBetween (now) dueDate}} days remaining ``` ## monthName Returns the full name of the month. ```handlebars theme={null} {{monthName date}} ``` **Examples:** ```handlebars theme={null} {{monthName "2024-12-15"}} ``` **Output:** `December` ## dayName Returns the name of the day of the week. ```handlebars theme={null} {{dayName date}} ``` **Examples:** ```handlebars theme={null} {{dayName "2024-12-15"}} ``` **Output:** `Sunday` ## Practical Examples ### Invoice Header ```handlebars theme={null}Invoice Date: {{formatDate invoiceDate "MMMM D, YYYY"}}
Due Date: {{formatDate dueDate "MMMM D, YYYY"}}
Payment due within 30 days
Invoice Date: {{formatDate invoiceDate "MMM D, YYYY"}}
Due Date: {{formatDate (addDays invoiceDate 30) "MMM D, YYYY"}}
{{dayName eventDate}}, {{formatDate eventDate "MMMM D, YYYY"}}
{{formatTime startTime "12"}} - {{formatTime endTime "12"}}
This invoice is {{daysBetween dueDate}} days overdue.
{{monthName periodStart}} {{formatDate periodStart "YYYY"}}
{{formatDate periodStart "MMM D"}} - {{formatDate periodEnd "MMM D, YYYY"}}
No items found.
{{else}} {{#each items}}...{{/each}} {{/if}} {{#if (isEmpty notes)}}No additional notes
{{else}}{{notes}}
{{/if}} ``` ## isNotEmpty Returns `true` if the value is NOT empty. ```handlebars theme={null} {{isNotEmpty "hello"}} ``` **Output:** `true` ```handlebars theme={null} {{#if (isNotEmpty customer.phone)}}Phone: {{customer.phone}}
{{/if}} {{#if (isNotEmpty attachments)}}Notes: {{default notes "No additional notes"}}
``` ```handlebars theme={null}No orders yet.
Start shopping{{customer.company}}
{{/if}} {{#if (isNotEmpty billingAddress)}}| {{this.name}} | {{this.quantity}} | {{currency this.unitPrice "USD"}} | {{currency (multiply this.quantity this.unitPrice) "USD"}} |
Subtotal: {{currency subtotal "USD"}}
Tax ({{multiply taxRate 100}}%): {{currency (multiply subtotal taxRate) "USD"}}
Shipping: {{currency shipping "USD"}}
Total: {{currency (add (add subtotal (multiply subtotal taxRate)) shipping) "USD"}}
{{round (multiply (divide completed total) 100)}}% complete
``` ### Pagination ```handlebars theme={null} Page {{currentPage}} of {{ceil (divide totalItems itemsPerPage)}} ``` # Number Formatting Helpers Source: https://docs.fileloom.io/helpers/numbers Format numbers as currency, percentages, file sizes, and more with formatNumber, currency, percentage, formatBytes, and ordinal. Number formatting helpers display numbers in human-readable formats. ## formatNumber Formats a number with thousands separators and decimal places. ```handlebars theme={null} {{formatNumber 1234567.89}} {{formatNumber 1234567.89 0}} {{formatNumber 1234567.89 2 "," "."}} ``` | Argument | Type | Default | Description | | -------------- | ------ | -------- | ------------------- | | `number` | number | required | Number to format | | `decimals` | number | 2 | Decimal places | | `thousandsSep` | string | "," | Thousands separator | | `decimalSep` | string | "." | Decimal separator | **Examples:** ```handlebars theme={null} {{formatNumber 1234567}} ``` **Output:** `1,234,567.00` ```handlebars theme={null} {{formatNumber 1234567 0}} ``` **Output:** `1,234,567` ```handlebars theme={null} {{! European format }} {{formatNumber 1234567.89 2 "." ","}} ``` **Output:** `1.234.567,89` ## currency Formats a number as currency with proper symbol and locale. ```handlebars theme={null} {{currency 1234.56 "USD"}} {{currency 1234.56 "EUR" "de-DE"}} ``` | Argument | Type | Default | Description | | -------------- | ------ | -------- | ---------------------- | | `amount` | number | required | Amount to format | | `currencyCode` | string | "USD" | ISO 4217 currency code | | `locale` | string | "en-US" | Locale for formatting | **Examples:** ```handlebars theme={null} {{currency 1234.56 "USD"}} ``` **Output:** `$1,234.56` ```handlebars theme={null} {{currency 1234.56 "EUR"}} ``` **Output:** `€1,234.56` ```handlebars theme={null} {{currency 1234.56 "GBP"}} ``` **Output:** `£1,234.56` ```handlebars theme={null} {{currency 1234.56 "JPY"}} ``` **Output:** `¥1,235` (JPY has no decimals) ```handlebars theme={null} {{! German locale }} {{currency 1234.56 "EUR" "de-DE"}} ``` **Output:** `1.234,56 €` ### Supported Currency Codes Common currency codes include: | Code | Currency | Symbol | | ---- | ----------------- | ------ | | USD | US Dollar | \$ | | EUR | Euro | € | | GBP | British Pound | £ | | JPY | Japanese Yen | ¥ | | CNY | Chinese Yuan | ¥ | | INR | Indian Rupee | ₹ | | CAD | Canadian Dollar | C\$ | | AUD | Australian Dollar | A\$ | | BRL | Brazilian Real | R\$ | | KRW | Korean Won | ₩ | ## percentage Calculates and formats a percentage. ```handlebars theme={null} {{percentage 75 100}} {{percentage 3 4 2}} ``` | Argument | Type | Default | Description | | ---------- | ------ | -------- | -------------- | | `value` | number | required | The part | | `total` | number | 1 | The whole | | `decimals` | number | 1 | Decimal places | **Examples:** ```handlebars theme={null} {{percentage 75 100}} ``` **Output:** `75.0%` ```handlebars theme={null} {{percentage 1 3 2}} ``` **Output:** `33.33%` ```handlebars theme={null} {{percentage completed total 0}} ``` ## formatBytes Formats bytes into human-readable file sizes. ```handlebars theme={null} {{formatBytes 1024}} {{formatBytes 1536000 1}} ``` | Argument | Type | Default | Description | | ---------- | ------ | -------- | -------------- | | `bytes` | number | required | Size in bytes | | `decimals` | number | 2 | Decimal places | **Examples:** ```handlebars theme={null} {{formatBytes 0}} ``` **Output:** `0 Bytes` ```handlebars theme={null} {{formatBytes 1024}} ``` **Output:** `1 KB` ```handlebars theme={null} {{formatBytes 1536000}} ``` **Output:** `1.46 MB` ```handlebars theme={null} {{formatBytes 1073741824}} ``` **Output:** `1 GB` | Input | Output | | ------------- | --------- | | 500 | 500 Bytes | | 1024 | 1 KB | | 1048576 | 1 MB | | 1073741824 | 1 GB | | 1099511627776 | 1 TB | ## ordinal Adds ordinal suffix to a number (1st, 2nd, 3rd, etc.). ```handlebars theme={null} {{ordinal 1}} {{ordinal 2}} {{ordinal 3}} {{ordinal 4}} ``` **Output:** `1st`, `2nd`, `3rd`, `4th` **Examples:** ```handlebars theme={null} {{ordinal 21}} {{ordinal 22}} {{ordinal 23}} {{ordinal 24}} {{ordinal 11}} {{ordinal 12}} {{ordinal 13}} ``` **Use cases:** ```handlebars theme={null}{{ordinal position}} place
{{ordinal day}} of {{monthName date}}
``` ## Practical Examples ### Invoice Line Items ```handlebars theme={null}| Item | Qty | Unit Price | Total |
|---|---|---|---|
| {{this.name}} | {{formatNumber this.quantity 0}} | {{currency this.unitPrice "USD"}} | {{currency (multiply this.quantity this.unitPrice) "USD"}} |
Tasks: {{completed}} of {{total}} ({{percentage completed total 0}})
Budget: {{currency spent "USD"}} of {{currency budget "USD"}} ({{percentage spent budget 0}})
Subtotal: {{currency subtotal currency}}
Tax: {{currency tax currency}}
Total: {{currency total currency}}
Eligible for bulk discount!
{{/if}} {{#if (and isPaid (not isRefunded))}} Payment Complete {{/if}} {{#if (eq status "active")}} Active {{/if}} ``` ### Helpers in Loops Use helpers inside `#each`: ```handlebars theme={null} {{#each items}}{{truncate description 150}}
Read more ``` ### Clean Phone Display ```handlebars theme={null} {{! Format: (555) 123-4567 from 5551234567 }} ({{substring phone 0 3}}) {{substring phone 3 6}}-{{substring phone 6 10}} ``` ### Text Separator ```handlebars theme={null}
{{repeat "=" 60}}
{{padEnd "Item" 30}}{{padStart "Amount" 25}}
{{repeat "=" 60}}
```
# Text Transformation Helpers
Source: https://docs.fileloom.io/helpers/text
Transform text case and format with uppercase, lowercase, capitalize, titleCase, slugify, and more.
Text transformation helpers change the case and format of text strings.
## uppercase
Converts text to UPPERCASE.
```handlebars theme={null}
{{uppercase "hello world"}}
```
**Output:** `HELLO WORLD`
**Use cases:**
* Headers and titles
* Status badges
* Emphasis text
```handlebars theme={null}
{{uppercase status}}
```
## lowercase
Converts text to lowercase.
```handlebars theme={null}
{{lowercase "Hello World"}}
```
**Output:** `hello world`
**Use cases:**
* Email addresses
* URLs
* Normalizing user input
```handlebars theme={null}
{{email}}
```
## capitalize
Capitalizes the first letter, lowercases the rest.
```handlebars theme={null}
{{capitalize "hello WORLD"}}
```
**Output:** `Hello world`
**Use cases:**
* Sentence beginnings
* Single-word labels
```handlebars theme={null}
Status: {{capitalize status}}
``` ## titleCase Capitalizes the first letter of each word. ```handlebars theme={null} {{titleCase "hello world example"}} ``` **Output:** `Hello World Example` **Use cases:** * Names * Titles * Headings ```handlebars theme={null}| Description | Qty | Price |
|---|---|---|
| {{this.description}} | {{this.quantity}} | {{currency this.price "USD"}} |
| Total | {{currency total "USD"}} | |
Your order #{{orderNumber}} is confirmed.
``` With data `{"name": "John", "orderNumber": "12345"}`: ```html theme={null}Your order #12345 is confirmed.
``` ## Nested Properties Access nested object properties with dot notation: ```handlebars theme={null}{{customer.name}}
{{customer.address.street}}
{{customer.address.city}}, {{customer.address.state}} {{customer.address.zip}}
``` With data: ```json theme={null} { "customer": { "name": "Acme Corp", "address": { "street": "123 Main St", "city": "San Francisco", "state": "CA", "zip": "94102" } } } ``` ## HTML Escaping By default, Handlebars escapes HTML characters for security: ```handlebars theme={null} {{description}} ``` Input: `` Output: `<script>alert('xss')</script>` To output raw HTML (use carefully): ```handlebars theme={null} {{{rawHtml}}} ```Payment required
{{/unless}} ``` ## Loops ### Each Iterate over arrays: ```handlebars theme={null}| {{this.name}} | {{this.quantity}} | {{currency this.price "USD"}} |
{{@key}}: {{this}}
{{/each}} ``` With data `{"person": {"name": "John", "age": 30}}`: ```html theme={null}name: John
age: 30
``` ## Using Helpers Helpers transform or format data: ```handlebars theme={null} {{! Single argument }} {{uppercase name}} {{! Multiple arguments }} {{currency amount "EUR"}} {{! With string literals }} {{formatDate date "MMMM D, YYYY"}} {{! Nested helpers }} {{currency (multiply price quantity) "USD"}} ``` ### Common Helpers ```handlebars theme={null} {{! Text }} {{uppercase "hello"}} → HELLO {{lowercase "HELLO"}} → hello {{capitalize "john doe"}} → John doe {{titleCase "john doe"}} → John Doe {{! Numbers }} {{currency 1234.5 "USD"}} → $1,234.50 {{formatNumber 1234567 0}} → 1,234,567 {{percentage 75 100}} → 75.0% {{! Dates }} {{formatDate date "YYYY-MM-DD"}} → 2024-12-15 {{formatDate date "MMMM D, YYYY"}} → December 15, 2024 {{now "YYYY"}} → 2024 {{! Math }} {{add 10 5}} → 15 {{multiply 10 5}} → 50 {{round 3.7}} → 4 ``` See [Helpers Reference](/helpers/overview) for all 70+ helpers. ## Comments Add comments that won't appear in output: ```handlebars theme={null} {{! This is a comment }} {{!-- This is a multi-line comment --}} ``` ## Whitespace Control Control whitespace with `~`: ```handlebars theme={null} {{#each items ~}} {{this.name}} {{~/each}} ``` The `~` removes whitespace on that side of the tag. ## Partials (Reusable Snippets) While Fileloom doesn't support custom partials, you can achieve reusability with: 1. **CSS classes** for consistent styling 2. **Helper functions** for data transformation 3. **Template duplication** for similar documents ## Practical Examples ### Invoice Line Items with Totals ```handlebars theme={null}| Description | Qty | Price | Total |
|---|---|---|---|
| {{this.description}} | {{this.quantity}} | {{currency this.unitPrice "USD"}} | {{currency (multiply this.quantity this.unitPrice) "USD"}} |
| Subtotal | {{currency subtotal "USD"}} | ||
| Tax ({{percentage taxRate 1 0}}) | {{currency tax "USD"}} | ||
| Total | {{currency total "USD"}} | ||
Customer: {{customer.name}}
Total: {{currency total "USD"}}
123 Your Street, Your City
contact@yourcompany.com