> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hocdoc.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates and variables

> Save offers as templates, start new offers from them and fill texts automatically with variables when you send.

With a template you do not start a new offer from zero. With variables you write a text once, and HocDoc fills in the values when you send. A template with questions asks you for the details that should flow into the texts before you start.

> [!NOTE]
>
> You can save, edit, delete and use templates from the Member role. Viewers see the list of templates without these buttons. More under [Team and roles](https://docs.hocdoc.com/en/guides/team-and-roles.md).

## Save an offer as a template

**1. Open the dialog**

Open the offer's detail page and choose **Save as template**. The same entry exists in the offer list, in the row's menu.

**2. Enter the details**

**Name** is prefilled with the offer's title (at most 120 characters). **Description (optional)** takes up to 500 characters. **Offer type (optional)** is a free short text, for example "Website relaunch" (at most 80 characters). Questions are also optional, see below.

**3. Save**

Choose **Save template**. Afterwards "Template saved" appears with the link **Go to templates**.

The template takes over the draft as it is when saving, including its [language](https://docs.hocdoc.com/en/guides/language-per-offer.md). An offer from the template starts in this language. It does not take recipient, send data and answers with it. Placeholders in the texts stay. If the draft is not valid, HocDoc does not save and reports "The draft is not valid yet" with the reasons.

A workspace can have at most 200 templates. The **Templates** page shows the count ("12 of 200 templates"), and so does the dialog ("12 of 200 templates used."). Once the limit is reached, HocDoc saves no further template. Delete one you no longer need first.

## Manage templates

On the **Templates** page there is the search field "Search templates" ("Search by name or description"). It searches name, description and offer type and filters immediately. If no template matches, it says "No templates found" with **Reset search**.

Every card on the **Templates** page shows name, number of sections, description, offer type, number of questions, the structure as a preview and the creation date. The newest template comes first. The card's menu has the entries **Edit**, **Delete** and, on the Team plan, **A/B test**:

* **Edit** changes name, description, offer type and questions. The template's content stays unchanged.
* **Delete** asks for confirmation ("Delete template?") and deletes permanently. Offers created from the template are kept.
* **A/B test** opens the page for tests (see [A/B tests for templates](#ab-tests-for-templates)).

## A/B tests for templates

With an A/B test you pit two versions of individual sections against each other. A/B tests are available on the Team plan. Only owners and admins create tests, change variant B and end tests. While a test runs, the card carries the badge "A/B test running".

**1. Create a test**

In the template card's menu, choose **A/B test**. Under "Create a test", choose up to 3 sections under "Sections with variant B" and then **Create a test**. At most one test runs per template. Locked sections cannot be tested, so remove the lock first.

**2. Write variant B**

Under "Variants" you switch between "Variant A" and "Variant B". A shows the section as it is in the template today and cannot be edited. B starts as a copy. You change it as in the builder, and the preview shows variant B. Save with **Save variant B**.

**3. Create offers**

Every new offer from the template randomly gets all A or all B, never mixed. The assignment is shown on the offer page ("Variant B from the A/B test …"). A duplicate does not take part.

**4. Evaluate and end**

The "Evaluation" card shows per variant: Offers created, Sent, Opened, Test sections fully seen, Time on the test sections, Accepted and Won value. Counting starts at sending. As long as a variant has fewer than 20 sent offers, it says "Not enough data yet". The numbers are a snapshot, not a verdict. To end, you choose **Keep A** (the template stays, B is discarded) or **Use B** (B replaces A in the template). Offers already created stay as they are.

As soon as the first offer from the test exists, variant B is fixed. Otherwise the numbers would mix. The result stays under "Finished tests" as a record. **Use B** does not work if a test section in the template was changed since the start or has been locked in the meantime. Choose **Keep A** then.

## Locked sections

Admins and owners lock individual sections in the builder (**Lock section**). The lock travels with the template into offers created from it. Members cannot change, hide, delete or move locked sections. They see a lock and the note "Locked, only admins can change it". With **Remove lock**, admins and owners take the lock off. Locked sections are available on the Team plan. A member does not create a template with locked sections. More under [Approval before sending](https://docs.hocdoc.com/en/guides/team-and-roles.md#locked-sections).

## Start an offer from a template

There are two ways:

* **Templates** page: **Create offer** on the card.
* **New offer** page, **From template** area: **Use template** on the card.

If the template has no questions, HocDoc creates an offer with the status "Draft" right away and opens its detail page. The title is the template's name, and you change it there. If the template has questions, you first get to the interview (see below).

## Variables in texts

A variable sits in double curly braces, for example `{{company}}`. You can write it into any text of a section. When you send, HocDoc replaces it with the value. Your draft keeps the placeholders, and the sent version contains the filled-in text.

### Built-in variables

| Variable | Value | Where from |
| - | - | - |
| `{{company}}` or `{{firma}}` | Recipient's company | Send dialog, **Company (optional)** |
| `{{name}}` | Recipient's name | Send dialog, **Recipient name** |
| `{{email}}` | Recipient's email | Send dialog, **Recipient email** |
| `{{sender}}` or `{{absender}}` | Your sender name | **Settings**, **Sender** area, **Sender name** field. If it is empty, the workspace name applies |
| `{{date}}` or `{{datum}}` | Date of sending | Day of sending |
| `{{valid_until}}` or `{{gueltig_bis}}` | Expiry date | Send dialog, **Valid until** |

Both spellings of a variable are equivalent and deliver the same value, in the send, in the check, in the preview and in the approval. `{{name}}` and `{{email}}` only exist in one spelling. The builder and the template editor show the spelling of your interface language. Texts that are already saved are not rewritten. HocDoc rejects new questions with the names `company`, `sender`, `date` or `valid_until`, just like `firma`. An existing question with one of these names stays, and the built-in value wins.

Both date values appear as a calendar date in the workspace's time zone. There is no first name, last name or salutation. The recipient has a single name field.

In the builder, the **Variables** tab lists all placeholders. A click copies the placeholder to the clipboard ("Copied"). You paste it into the text yourself, and HocDoc does not insert it at the cursor position.

### Notation

A name begins with a lowercase letter. Lowercase letters, digits or underscores follow. It is at most 40 characters long. Uppercase letters and umlauts are not allowed: `{{Firma}}` is invalid. Spaces directly inside the braces do not matter.

There is no character to write double curly braces literally.

### Preview

The **Preview** in the builder fills in what is already known: answers from the interview, sender and date, and after a send also the data of the last recipient. Placeholders without a value stay in place and are highlighted ("Highlighted placeholders are filled in when you send."). Before the first send this affects the recipient's data, which is only set in the send dialog. The preview on the detail page shows the draft with highlighted placeholders.

### Open variables block sending

A variable is open if it gets no value when sending. There are four cases:

* Unknown name: your own variable for which the offer has no question.
* Empty value: for example `{{firma}}` with an empty **Company (optional)** field, or a question without an answer.
* Invalid name: for example `{{Firma}}`.
* Double brace without a counterpart: for example `{{firma}` or `{firma}}`.

The send dialog then shows "Sending blocked: 1 variable without a value" (for several, "Sending blocked: 2 variables without a value"). The list names the affected sections for each variable and what to do. In the builder, a click on an entry jumps to the first affected section. As long as anything is open, **Send** stays locked. Only visible sections are checked, hidden ones do not count.

### Where nothing is replaced

* The offer's title and **Personal message (optional)** in the send dialog. If double curly braces appear there, sending is blocked and the dialog asks you to change the text.
* **Button text** for the link after acceptance. Double curly braces are not allowed there either.
* Image addresses of logos.

## Template with questions

A template can carry up to 20 questions. Each question fills its own variable. Your own variables only come into being this way.

**1. Write the variable into the texts**

Write the placeholder into the offer's texts, for example `{{projektziel}}`. Do this before saving, because the template takes over the draft as it is then.

**2. Open the dialog**

On the detail page, choose **Save as template**. Under **Questions (optional)**, your own variables from the texts are already entered, with empty question text. With **Add question** you create more rows. In the dialog from the offer list nothing is prefilled.

**3. Fill in question and variable**

Write the question text in **Question 1** (at most 200 characters) and the name without braces in **Variable 1**, for example `projektziel`. If **Variable 1** is empty, HocDoc suggests a name from the question text when you leave the question field.

Every row needs question text and variable. A row with empty question text prevents saving ("Question 1: The question can't be empty."). Fill it in or remove it. A custom name must not be a built-in variable and may only appear once.

## The interview before you start

For a template with questions, **Create offer** and **Use template** first lead to the **Questions for the offer** page. For each question there is a text field for up to 2000 characters, with the placeholder below it. No question is required. **Create offer** creates the offer, **Cancel** leads to the **New offer** page.

The answers are stored as a copy on the offer. From the Member role you change them on the detail page under "Answers from the interview" or in the builder in the **Variables** tab, each with **Save answers**. Viewers see the answers on the detail page but do not change them.

* If an answer is missing whose variable is in a visible text, sending is blocked until you add it.
* Changed answers apply from the next send. Versions already sent stay as they are.
* A duplicated offer takes questions and answers with it.
* If you later change the template's questions, existing offers do not change.

Next up is [Sending](https://docs.hocdoc.com/en/guides/sending.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.