# Working with the template editor

URL: https://help.hubhus.com/kb/working-with-the-template-editor
Category: Campaigns & Lead Management / Templates
Updated: 2026-09-28T14:40:57.861+00:00

Summary: Access: Via Campaign settings → Emails, SMS, or Editor or any automation rule. Left side: code editor (HTML/raw or plain text). Right side: live preview with real lead data. Ctrl+K / Cmd+K → search and insert placeholders. Use @include(component-name) to insert reusable components. Built-in examples for @if/@else , @foreach , variables, and JSON data. SMS: auto character + message count. Always test with edge-case leads (empty fields, multiple events).

The template editor is used to create and edit email, SMS, and HTML component templates with live preview using real lead data - making it easy to test dynamic content before sending.

## 5 things to know

1. **Editor layout**. **Left:** code editor (plain text or HTML/raw). **Right:** live preview panel. Click **Update result** to refresh the preview with current code + selected lead. Use the Lead ID arrows or type a specific ID to test with different leads. The placeholders panel lists all available dynamic fields with descriptions.
2. **Inserting placeholders (Ctrl+K)**. Press **Ctrl+K** (Win/Linux) or **Cmd+K** (Mac) to open the placeholder search. Type a keyword (e.g. "name", "event", "phone") and click to insert. This is faster than browsing the panel. Common placeholders: `%lead_name%`, `%lead_firstname%`, `%event_datetime%`, `%assigned_person_name%`.
3. **Conditional logic and loops**. Use built-in examples (expandable sections in the editor): **Conditionals:** `@if(%assigned_person_name%){ ... }@else{ ... }@endif`. **Loops:** `@foreach(calendarEvents){ %event_title% }@endforeach`. Don't write these from scratch - copy from the built-in examples and customize. Always add `@else` fallback for important conditionals.
4. **Reusable components with @include**. Insert pre-built HTML components using `@include(component-name)`. Example: `@include(booking-signatur)`, `@include(e-mail-signatur)`. Click **Select template** to choose a starting template or insert a component. Components update everywhere they're used when edited - centralized maintenance.
5. **SMS character counting**. For SMS templates, the editor automatically shows character count and number of SMS segments. Standard SMS: 160 chars = 1 message. With special characters (æøå): 70 chars = 1 message. Use `%lead_firstname%` (not `%lead_name%`) to save characters. Preview with multiple leads - placeholder lengths vary by lead.

**Read more**

### Common placeholder reference

**Lead information**

- `%lead_name%` - full name
- `%lead_firstname%` - first name only (saves space in SMS)
- `%lead_phone%` - phone number
- `%lead_phone_readable%` - formatted phone number
- `%lead_email%` - email address

**Event / booking information**

- `%event_title%` - calendar event title
- `%event_datetime%` - event date and time (formatted)
- `%event_location%` - event location / address
- `%event_start_datetime_db%` - event start in DB format (for hh-date components)
- `%event_resources_names%` - booked resource names

**Assigned person**

- `%assigned_person_name%` - name of assigned consultant
- `%assigned_person_email%` - consultant's email
- `%assigned_person_phone%` - consultant's phone number

### Variables and file loops

**Variables** - store and reuse values within a template:

```
{- var name = %lead_name% -}

Lead: {-name-}
```

**Loop through uploaded files** (e.g. photos, documents):

```
Uploaded files:

@files(billeder-fra-opgave) - {file.name} ({file.size} kB)
@endforeach_file
```

**Including reusable components:**

```
@include(booking-knap-faelles)
@include(signatur)
```

### Troubleshooting

**Placeholder shows literal text (e.g. `%lead_name%` instead of the name)**

- Check spelling of the placeholder
- Ensure the field exists in this campaign (not all campaigns have the same fields)
- Verify the selected lead has data in that field - try a different lead

**Preview does not update after editing**

- Click **Update result** explicitly - preview is not auto-refreshed on every keystroke
- Check for syntax errors in @if blocks or @foreach loops
- Try switching to a different lead and back

**Loop shows no content**

- Verify the selected test lead actually has data to loop through (events, uploaded files, etc.)
- Test with a different lead that has multiple items
- Check loop syntax against the built-in examples - a missing @endforeach or wrong scope name will cause empty output

## Related articles

- https://help.hubhus.com/kb/working-with-html-components
- https://help.hubhus.com/kb/understanding-placeholders-and-dynamic-content
- https://help.hubhus.com/kb/how-to-set-up-automations
