---
template: "page.peb"
title: "Document Builder Template Tags"
displayName: "Document Builder Template Tags"
description: "Understand Data Merge template tags, Data Context Definitions, formatting filters, loops, and current date values in Document Builder."
category: "support"
contentType: "guide"
audience: "admin"
tags: "support,salesforce,document builder,data merge,templates,merge tags,data context,pebble,twig"
section: "support"
seoTitle: "Document Builder Template Tags"
seoDescription: "Learn how iDialogue Document Builder uses Pebble-style merge tags, Data Context Definitions, and system date tags for Salesforce document templates."
---

## Document Builder Template Tags

Document Builder Data Merge templates use template tags to insert Salesforce data into document HTML.

Most admins should use the embedded AI Assistant in Document Builder. The assistant can read the active template, understand the connected Data Context Definition, and insert the correct tag syntax for you.

This guide is for admins who also want to work in source mode, review generated tags, or make careful manual edits to merge fields, repeated rows, conditions, and formatting.

## How template tags work

A Data Merge template has two parts:

1. The document layout, which is the HTML source in Document Builder.
2. The data shape, which comes from the selected Data Context Definition.

The Data Context Definition, or DCD, tells iDialogue which Salesforce records and fields are available when the template is merged. The template tags must match the names exposed by the DCD. If the DCD exposes an Opportunity as `opportunity`, the tag uses `{{ opportunity.Name }}`. If the DCD exposes Account as `account`, the tag uses `{{ account.Name }}`.

Template tags are case-sensitive. `{{ account.Name }}` and `{{ Account.Name }}` are different paths.

## Pebble and Twig-style syntax

iDialogue Data Merge templates use Pebble-style syntax. Pebble is an open source Java template engine with syntax that is similar to Twig.

The most common tag types are:

```html
{{ account.Name }}
```

Inserts a value.

```html
{% if opportunity.Amount %}
  {{ opportunity.Amount | formatCurrency() }}
{% endif %}
```

Shows content conditionally.

```html
{% for item in items %}
  <tr>
    <td>{{ item.productName }}</td>
    <td>{{ item.quantity | formatNumber(format="#,##0") }}</td>
    <td>{{ item.totalPrice | formatCurrency() }}</td>
  </tr>
{% endfor %}
```

Repeats content for a list of records.

```html
{# Internal note for a template editor #}
```

Adds a source comment that does not appear in the merged document.

## Current date and date/time

Use the reserved `system` namespace for values that are generated at merge time and do not come from Salesforce.

```html
{{ system.currentDate }}
```

Inserts the current date as an ISO date, such as `2026-07-08`.

```html
{{ system.currentDate | formatDate(pattern="MMMM d, yyyy") }}
```

Inserts a formatted current date, such as `July 8, 2026`.

```html
{{ system.currentDateTime | formatDateTime(pattern="MMMM d, yyyy h:mm a z") }}
```

Inserts a formatted current date and time, such as `July 8, 2026 9:30 AM PDT`.

Use `system.currentDate` for statement dates, generated dates, and simple "today" placeholders. Use `system.currentDateTime` only when the document needs a time or timestamp.

Do not use `system.currentDate` for a business date stored in Salesforce. For Opportunity Close Date, Quote Expiration Date, Contract Start Date, Renewal Date, Invoice Due Date, or similar fields, use the field supplied by the DCD.

## Formatting values

Use formatting filters after the value with a pipe character.

```html
{{ opportunity.Amount | formatCurrency() }}
{{ item.quantity | formatNumber(format="#,##0") }}
{{ item.discountPercent | formatPercent() }}
{{ opportunity.CloseDate | formatDate(pattern="MMM d, yyyy") }}
{{ system.currentDateTime | formatDateTime(pattern="yyyy-MM-dd HH:mm z") }}
```

Common date patterns:

- `MMMM d, yyyy`: July 8, 2026
- `MMM d, yyyy`: Jul 8, 2026
- `MM/dd/yyyy`: 07/08/2026
- `yyyy-MM-dd`: 2026-07-08

Date and date/time formatting uses the render request timezone and locale when Document Builder supplies them.

## Opportunity quote examples

The exact tag names depend on your DCD, but an Opportunity quote often includes data like this:

```html
<h1>Quote for {{ account.Name }}</h1>

<p>Prepared for {{ primaryContact.Name }}</p>
<p>Opportunity: {{ opportunity.Name }}</p>
<p>Close Date: {{ opportunity.CloseDate | formatDate(pattern="MMM d, yyyy") }}</p>
<p>Quote Date: {{ system.currentDate | formatDate(pattern="MMMM d, yyyy") }}</p>

<table>
  <thead>
    <tr>
      <th>Product</th>
      <th>Quantity</th>
      <th>Unit Price</th>
      <th>Total</th>
    </tr>
  </thead>
  <tbody>
    {% for item in items %}
    <tr>
      <td>{{ item.productName }}</td>
      <td>{{ item.quantity | formatNumber(format="#,##0") }}</td>
      <td>{{ item.unitPrice | formatCurrency() }}</td>
      <td>{{ item.totalPrice | formatCurrency() }}</td>
    </tr>
    {% endfor %}
  </tbody>
</table>

<p>Subtotal: {{ totals.subtotal | formatCurrency() }}</p>
<p>Total: {{ totals.grandTotal | formatCurrency() }}</p>
```

In this example:

- `account`, `primaryContact`, `opportunity`, `items`, and `totals` are names supplied by the DCD.
- `item` is a local loop variable chosen inside the `{% for item in items %}` block.
- `system.currentDate` is supplied by the renderer and does not require a DCD field.

## Account agreement and contract examples

An Account-based agreement or contract DCD might expose the Account, primary contact, active contract, and renewal details.

```html
<h1>Services Agreement</h1>

<p>This agreement is entered into on {{ system.currentDate | formatDate(pattern="MMMM d, yyyy") }}.</p>

<p>Customer: {{ account.Name }}</p>
<p>Billing Address: {{ account.BillingStreet }}, {{ account.BillingCity }}, {{ account.BillingState }} {{ account.BillingPostalCode }}</p>

{% if primaryContact.Email %}
<p>Primary Contact: {{ primaryContact.Name }} ({{ primaryContact.Email }})</p>
{% endif %}

<p>Contract Start: {{ contract.StartDate | formatDate(pattern="MMM d, yyyy") }}</p>
<p>Contract End: {{ contract.EndDate | formatDate(pattern="MMM d, yyyy") }}</p>
<p>Renewal Term: {{ renewal.termMonths | formatNumber(format="#,##0") }} months</p>
```

For legal or billing terms, prefer values collected from Salesforce by the DCD. Use `system.currentDate` only for the date the document is generated or signed when that is the intended business meaning.

## Working with Data Context Definitions

Before editing tags manually, confirm the active DCD:

- The DCD controls which Salesforce object starts the merge, such as Account or Opportunity.
- The DCD controls related records, such as Opportunity Line Items, Contacts, Contracts, or Quotes.
- The DCD controls aliases, such as `opportunity`, `account`, `items`, or `totals`.
- The DCD controls whether a dataset is one record or many records.

Use a loop only when the DCD exposes a many-record dataset.

```html
{% for contact in contacts %}
  <p>{{ contact.Name }} - {{ contact.Email }}</p>
{% endfor %}
```

Do not guess dataset names. If a tag renders blank or remains unresolved, check the DCD or ask the embedded AI Assistant to inspect the available field map.

## Common mistakes

Avoid Salesforce merge syntax in Data Merge templates:

```html
{!Opportunity.Name}
```

Use Pebble-style syntax instead:

```html
{{ opportunity.Name }}
```

Avoid single-brace placeholders:

```html
[date]
{Account.Name}
```

Use canonical Data Merge tags:

```html
{{ system.currentDate | formatDate(pattern="MMMM d, yyyy") }}
{{ account.Name }}
```

Keep Pebble tags unescaped in source mode. Inside `{{ ... }}` and `{% ... %}`, use `>`, `<`, and quotes directly instead of HTML entities like `&gt;` or `&quot;`.

## Troubleshooting

If the merged document still shows `{{ account.Name }}`, the template may not have been rendered as a Data Merge template, or the source may contain invalid Pebble syntax.

If a value is blank, confirm the field is included in the DCD and populated on the Salesforce record.

If a repeated table has no rows, confirm the DCD exposes a many-record dataset and that the template loops over the correct dataset name.

If a date looks wrong, confirm whether the date should come from Salesforce or from `system.currentDate`. Business dates usually come from Salesforce fields. Generated dates usually use `system.currentDate`.

If a date format renders blank, check the input value and the formatting pattern. A common safe pattern is:

```html
{{ opportunity.CloseDate | formatDate(pattern="MMM d, yyyy") }}
```

When in doubt, use the embedded AI Assistant. Ask it to "show me the available merge tags for this template" or "replace [date] with today's date in the right format."
