Skip to content
This documentation is currently in preview, therefore subject to change.

Document Generation Overview

Build a Doc’s document generation capabilities allow you to create dynamic documents by combining templates with data sources. This page explains the core concepts behind the templating engine.


Templates and Data Sources

Document generation in Build a Doc requires two components:

  1. Template - A document (Word, Excel, HTML) containing placeholders and logic
  2. Data Source - Structured data (JSON, XML, CSV) that populates the placeholders (see Structure JSON Data for formatting guidance)

When you call a conversion action, Build a Doc merges the template and data source to produce the final document.


Template Expressions

Template expressions are special placeholders in your document that tell Build a Doc where to insert data.

The specific expression syntax differs depending on the document type

Word/Excel Syntax

Word and Excel use square brackets [] wrapped in double angle brackets <<>> for expressions:

<<[PropertyPath]>>

For complete syntax documentation, see Word Template Syntax and Excel Template Syntax.

HTML Syntax (Handlebars)

HTML templates use double curly brackets {{}} (Handlebars):

{{PropertyPath}}

Control Flows

Templates support control flow for conditional content and iteration.

Conditionals

Conditionals evaluate an expression and render the enclosed content only when the expression is true. Use <<if [Expression]>> ... <<else>> ... <</if>> for optional alternatives.

Example:

<<if [IsVIP]>>
VIP Customer Discount Applied
<<else>>
Standard pricing
<</if>>

Use comparisons (>, <, ==) or boolean fields. When placing conditionals inside tables, keep the start and end tags within the same table row so the table layout remains valid.

Loops

foreach repeats a block for each element in a collection: <<foreach [item in Items]>> ... <</foreach>>.

Example:

<<foreach [item in Items]>>
<<[item.Name]>> - <<[item.Price]>>
<</foreach>>

Put loop tags inside the table row you want repeated to duplicate the entire row per item. Use zero-based indexes (e.g., Products[0]) to reference specific elements when needed.


Output Formats

Build a Doc can output documents in multiple formats:

Input TypeOutput Formats
Word (.docx)PDF, HTML, DOCX, DOC, SVG, JPEG, PNG, BMP, GIF, TIFF
Excel (.xlsx)PDF, XLSX, XLS, HTML, CSV, ODS
HTMLPDF, HTML
PowerPoint (.pptx)PDF, PPTX

Processing Pipeline

  1. Input Validation - Verify template and data source formats
  2. Expression Parsing - Identify all template expressions
  3. Data Binding - Map expressions to data source values
  4. Evaluation - Evaluate conditionals and execute loops
  5. Rendering - Generate the output document
  6. Format Conversion - Convert to the requested output format