# Understanding @if/@else conditional logic

URL: https://help.hubhus.com/kb/understanding-if-else-conditional-logic
Category: Campaigns & Lead Management / Placeholders
Updated: 2026-09-28T14:40:23.158+00:00

Summary: Wrap content in @if(%field%){ ... }@endif . Add @else{ ... } for a fallback. Compare with == , != , &#126;= , &lt; , > . Combine checks with && (AND) or || (OR) - but not both together. Press CTRL+K / CMD+K in any template field to find placeholders instantly.

Conditional logic lets your email and SMS templates show or hide content based on the lead's actual data. Use it to personalize messages, add fallbacks, and build smart dynamic communications without writing code.

## 4 things to know

1. **Basic @if - show content only if a field has a value**. @if( `%assigned_person_name%`){ Your consultant is: `%assigned_person_name%` }@endif
  Note: `0`, `false`, `off`, `nej`, `no`, `n` all evaluate as **false** even though they are non-empty.
2. @if / @else - show different content per scenario
3. **Comparison operators - compare values precisely**. `==` equal · `!=` not equal · `~=` contains (case-insensitive) · `<` `<=` `>` `>=`
4. **Logical operators - combine multiple conditions**. AND: @if( `%field_a%` == X && `%field_b%` == Y){ ... }@endif OR: @if( `%field_a%` == X || `%field_a%` == Y){ ... }@endif
  **Important:** Parentheses are NOT supported. || is evaluated before `&&`. Don't mix both in the same expression.

**Read more**

### Nested @if statements

```
@if(%assigned_person_name%){
  Your consultant is: %assigned_person_name%

  @if(%assigned_person_phone%){
    Call %assigned_person_firstname% at: %assigned_person_phone%
  }@endif

}@else{
  You do not have a personal consultant yet.
}@endif
```

### Date comparison

```
@if(%lead_created_at% < @str2datetime[-2 weeks]){
  Lead is more than 2 weeks old
}@endif
```

### Finding placeholders with CTRL+K / CMD+K

Press CTRL+K (Windows) or CMD+K (Mac) in any template field to open the placeholder search. Search by natural words: "lead name", "event date", "address", "signature". This is the fastest way to find the exact placeholder and avoid typos.

### Best practices

- Use the slug value (not the label) when comparing select fields
- Always add `@else` for fallback content in customer-facing templates
- Use the editor's built-in examples section for for-loops, variables, and JSON patterns
- Test conditions with real leads before activating

## Related articles

- https://help.hubhus.com/kb/understanding-placeholders-and-dynamic-content
- https://help.hubhus.com/kb/how-does-the-messaging-system-work
- https://help.hubhus.com/kb/how-do-i-edit-email-templates
- https://help.hubhus.com/kb/building-workflows-in-hubhus
