Templates

Conditional blocks New

Conditional blocks support the following operators: == (equals), != (not equals), > (greater than), < (less than), >= (greater than or equal), <= (less than or equal).

Use conditional blocks to show different content based on a property value. Copy the snippet below and adapt the property names to your template. See example.

Syntax

There are two supported syntaxes:

Syntax 1: Ternary (inline)

Use this to show or replace a short piece of text on a single line:

{{property == 'value' ? 'Show this if true' : 'Show this if false'}}

Parts:

  • property — the HubSpot property name
  • == 'value' — the condition to evaluate
  • 'Show this if true' — output when condition is met
  • 'Show this if false' — output when condition is not met (use '' to show nothing)

Syntax 2: If/Else Block

Use this when you need to show or hide larger content — full sentences, paragraphs, or multiple lines:

{% if property == 'value' %} Content to show when true. {% else %} Content to show when false. {% endif %}

Without else (show nothing if false):

{% if property == 'value' %} Content to show when true. {% endif %}

With multiple conditions:

{% if property == 'value' %} Content A. {% elseif property == 'other' %} Content B. {% else %} Content C. {% endif %}

Supported Operations

Operator Meaning Example
(none) Truthy — true if property has any value {{is_premium ? 'Premium' : 'Standard'}}
== Equals {{dealstage == 'closedwon' ? 'Won' : 'In progress'}}
!= Not equals {{dealstage != 'closedlost' ? 'Active' : 'Lost'}}
> Greater than {{amount > 10000 ? 'High value' : 'Standard'}}
< Less than {{amount < 500 ? 'Low value' : 'Standard'}}
>= Greater than or equal {% if amount >= 5000 %}...{% endif %}
<= Less than or equal {% if numemployees <= 50 %}...{% endif %}

Examples

Equals (==)

{{dealstage == 'closedwon' ? 'Deal closed!' : 'Deal in progress.'}} {% if dealstage == 'closedwon' %} Congratulations! Your deal has been closed successfully. {% else %} Your deal is still in progress. {% endif %}

Not equal (!=)

{{dealstage != 'closedlost' ? 'Active deal' : 'This deal was lost.'}} {% if dealstage != 'closedlost' %} Your deal is still active. Our team will follow up shortly. {% else %} Unfortunately this deal was marked as lost. {% endif %}

Greater than (>)

{{amount > 10000 ? 'Premium client' : 'Standard client'}} {% if amount > 10000 %} As a premium client, you receive priority support and dedicated account management. {% else %} Contact us to learn about our premium plans. {% endif %}

Less than (<)

{{numemployees < 10 ? 'Small business' : 'Medium or large business'}} {% if numemployees < 10 %} This offer is exclusively available for small businesses. {% else %} Please contact our enterprise team for tailored pricing. {% endif %}

Greater than or equal (>=)

{% if amount >= 5000 %} You qualify for a 10% discount on your next order. {% else %} Reach €5,000 in purchases to unlock your discount. {% endif %}

Less than or equal (<=)

{% if numemployees <= 50 %} Your company qualifies for our SMB pricing plan. {% else %} Please contact our enterprise sales team for a custom quote. {% endif %}

Truthy check (no operator)

{{is_premium ? 'Premium' : 'Standard'}} {% if is_premium %} Your premium membership includes all features and priority support. {% else %} Upgrade to premium to unlock all features. {% endif %}

Multiple conditions (elseif)

{% if dealstage == 'closedwon' %} Thank you for your business! Your order is confirmed. {% elseif dealstage == 'contractsent' %} Your contract has been sent. Please review and sign at your earliest convenience. {% else %} Our team will be in touch soon to move things forward. {% endif %}

Multiple conditionals in one sentence (ternary)

{{firstname}}, your account is {{verified ? 'verified' : 'pending verification'}} and {{active ? 'active' : 'inactive'}}.

Missing Property Behavior

When a property used in a conditional is not found or has no value:

  • Ternary: the expression is replaced with the false value (the part after :); if '', nothing is shown
  • If/else block: the {% else %} content is shown; if there is no {% else %}, nothing is shown
Always ensure the properties you reference in conditionals exist in your HubSpot data to avoid unexpected empty content.