Skip to main content
Templates are the foundation of Fileloom. They combine HTML structure, CSS styling, and Handlebars placeholders to create dynamic, reusable PDF documents.

What is a Template?

A template is a saved document design that you can use repeatedly with different data. Instead of sending raw HTML with every API request, you:
  1. Create a template once in the dashboard
  2. Reference it by ID in API requests
  3. Pass only the dynamic data
{
  "templateId": "tpl_invoice_v2",
  "templateData": {
    "invoiceNumber": "INV-2024-001",
    "customerName": "Acme Corp",
    "total": 1250.00
  }
}

Template Components

Every template consists of:
ComponentDescription
HTMLDocument structure with Handlebars placeholders
CSSStyling (colors, fonts, layout)
SettingsPaper size, margins, orientation
Test DataSample JSON for previewing

Template vs Raw HTML

ApproachBest For
TemplatesRepeated documents (invoices, reports), team collaboration, version control
Raw HTMLOne-off documents, dynamic layouts, programmatic generation
Use templates for any document you’ll generate more than once. They’re faster (no HTML transfer), easier to maintain, and support versioning.

Creating Your First Template

1

Open Template Editor

Go to TemplatesCreate Template in the dashboard.
2

Write HTML

Create your document structure with Handlebars placeholders:
    <div class="invoice">
      <h1>Invoice #{{invoiceNumber}}</h1>
      <p>Customer: {{customer.name}}</p>
      <p>Total: {{currency total "USD"}}</p>
    </div>
3

Add CSS

Style your document in the CSS tab:
    .invoice {
      font-family: 'Inter', sans-serif;
      padding: 40px;
    }
    h1 { color: #333; }
4

Test with Data

Enter sample JSON in the Test Data tab:
    {
      "invoiceNumber": "INV-001",
      "customer": { "name": "Acme Corp" },
      "total": 1250.00
    }
5

Preview and Publish

Check the live preview, then click Publish to make it available via API.

Handlebars Basics

Fileloom uses Handlebars for dynamic content:
{{! Output a variable }}
{{variableName}}

{{! Access nested properties }}
{{customer.address.city}}

{{! Use helpers for formatting }}
{{currency amount "USD"}}
{{formatDate date "MMMM D, YYYY"}}

{{! Conditionals }}
{{#if isPaid}}Paid{{else}}Unpaid{{/if}}

{{! Loops }}
{{#each items}}
  <li>{{this.name}}: {{currency this.price "USD"}}</li>
{{/each}}
See Handlebars Basics for complete syntax guide.

Built-in Helpers

Fileloom includes 70+ helpers for common operations:

Using Templates via API

Reference your template by ID:
curl -X POST https://api.fileloom.io/v1/pdf/generate \
  -H "X-API-Key: fl_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "templateId": "tpl_abc123xyz",
    "templateData": {
      "invoiceNumber": "INV-2024-001",
      "items": [
        {"name": "Widget", "price": 29.99}
      ]
    }
  }'
Find template IDs in the dashboard templates list or template editor.

Next Steps