Understanding @if/@else conditional logic
Conditional logic allows your templates to show or hide specific parts of a message based on the data on the lead.
On this page
Jump to any section using the links below
Conditional logic allows your templates to show or hide specific parts of a message based on the data on the lead. This makes your Email and SMS communication dynamic, personalized, and much more powerful.
Hubhus uses a simple but flexible logic language built directly into the template editor.
Use the Editor to test logic and find placeholders instantly
Table of Contents
In any input field inside the editor, you can press:
CTRL + K (Windows)
CMD + K (Mac)
This opens the placeholder search modal, where you can quickly look up:
Lead placeholders (name, email, phone, address, etc.)
Event placeholders (date, time, ICS links, resource emails, duration, etc.)
HTML components (buttons, signatures, branding blocks)
Links to pages (
@page[...])Booking forms
Custom fields (API-based placeholders)
Assigned person & brand placeholders
You can search using natural words like:
“lead name”, “address”, “event date”, “signature”, “brand contact”.
Using this tool is the fastest and safest way to locate the correct placeholder and ensure your logic is valid.
Built-in reference examples inside the editor
At the bottom of the editor, you will find a full reference area with practical, copy/paste-klare eksempler, including:
Variables
For loops
Nested loops
JSON data examples
File examples
Calendar event examples
Campaign relations examples
Checklist examples
These examples are extremely useful when you want to test how logic behaves before using it in a live template.
Tip: “Under editor kan du også finde informationer om:”
Variables, For loops, JSON data examples, File examples, Calendar event examples, Campaign relations examples, Checklist examples.
Basic @if statement
Shows content only if the placeholder has a value:
Important:
These non-empty values still count as false:0, false, off, nej, no, n.
Everything else counts as true.
Basic @if / @else
Nested statements
Comparison operators
You can compare values using:
==equal!=not equal~=contains (case-insensitive)<,<=,>,>=Logical operators:
&&and||
Examples
Numeric or field comparison:
Date comparison:
Text comparison:
Contains check (~=)
Case-insensitive substring search:
Logical operators (&& and ||)
OR example
AND example
Important:
Parentheses are NOT supported.
If both operators are used, || is evaluated before &&.
Best practices
Use slugs, not labels, for select-field comparisons
Use
@elsefor fallback contentKeep logic simple and readable
Always test conditions with real leads
Use the CTRL+K / CMD+K modal to avoid placeholder mistakes
Look at the editor’s built-in examples when constructing loops or variables
Learning outcome
After reading this, you should understand:
How conditional logic works in Hubhus
How to use @if, @else, and @elseif
How to compare values safely
How to use contains, numeric, and text logic
How to troubleshoot unexpected behavior
How to use the editor’s built-in tools (CTRL+K / CMD+K + examples)
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article