How to Build Custom Templates with Handlebars Syntax
Why Custom Templates Matter
Pre-built templates are great for getting started, but every business has unique needs. Custom templates allow you to standardize your document creation process while maintaining the flexibility to adapt to specific requirements.
Getting Started with Handlebars
CreateDocs.ai uses Handlebars syntax for template variables. This makes templates powerful yet easy to understand.
Basic Variables
Use double curly braces to insert variables:
Dear {{clientName}},
Thank you for your interest in {{productName}}.
Conditional Sections
Use #if blocks to include content conditionally:
{{#if includeWarranty}}
This product comes with a {{warrantyPeriod}} warranty.
{{/if}}
Loops
Use #each to iterate over lists:
{{#each lineItems}}
- {{this.description}}: ${{this.amount}}
{{/each}}
Best Practices
- Use descriptive variable names:
{{clientCompanyName}}is better than{{name}} - Group related fields: Organize your template into logical sections
- Add default values: Provide sensible defaults for optional fields
- Test thoroughly: Generate sample documents with different data to catch edge cases
- Version your templates: Use our built-in version control to track changes
Advanced Techniques
Custom Helpers
Create reusable formatting functions:
{{formatCurrency totalAmount}}
{{formatDate signatureDate "MMMM D, YYYY"}}
Nested Templates
Include sub-templates for complex documents:
{{> headerPartial}}
{{> contractBody}}
{{> signatureBlock}}
Sharing Templates with Your Team
Once you have built a template, share it with your team through your workspace. Team members can use your template to generate documents while maintaining consistency across the organization.
Start with a built-in template
Use an existing template or build your own from scratch.
Go to Template Library