Learn more about If block branches
Contact Based
Examples for normal text
{% block if object.firstname %}
Hello {{ object.firstname }}, thanks for reaching out!
{% end block %}
- If the contact’s first name is Sam, the output would be: “Hello Ben*, thanks for reaching out!
- If the first name is blank, the whole block (including the greeting) is skipped entirely.
- block if: This is a custom HubL syntax used specifically in HubSpot CMS modules, especially in rich text or email templates, where block if is a wrapper that tells HubSpot to conditionally render a block of content only if a condition is true.
- object.firstname: This refers to the firstname property of the current object.
- If this is an email or template for contacts, object would be the contact record.
- So this is checking: "Does the contact have a first name?"
Examples for in tables
- If the contact has a first name, it displays their full name.
- {% block if object.firstname %} : This says: "Only show the content inside this block if object.firstname exists."
- It’s a conditional wrapper used in HubSpot’s CMS module templates (like email templates or drag-and-drop areas).
- object.firstname checks if the current object (probably a contact) has a first name set.
- object.lastname inserts the last name
- {% end block %} : Closes the conditional block.
- If object.firstname is empty or undefined, nothing inside this block will be shown — including the last name
Examples for deleting images, tables and text boxes
- If the token contains no value, delete everything between
{% block if object.contact_owner %} and{% end block %}
- In this case the property is empty so everything will be delete
- If the token does contain a value, then keep everything in between.
- {% block if object.contact_owner %}: This conditionally shows the entire block of content only if the contact has a value for the contact_owner property.
- In this case, we purposely left contact_owner blank, so this block will not render anything at all.
- That means: the entire chunk of HTML inside (table, images, text) gets skipped — like it was never there.
Deal Based
Examples for normal text
- If the dealname property has a value, it shows the message. If it's empty or missing, nothing is shown.
{% block if object.dealname %}
Hello! You’re working on the {{object.dealname}} deal.
{% end block %}
- {% block if object.dealname %}: This checks whether the dealname property exists and has a value.
- If dealname is blank or not set, then everything inside the block gets ignored — not rendered at all.
- "Hello! You’re working on the {{object.dealname}} deal.": This outputs a message that includes the deal name pulled from the current object.
- If the deal name is something like "Website Redesign", the final result will be:
"Hello! You’re working on the Website Redesign deal." - The syntax is HubL’s way of inserting dynamic data
- {% end block %}: Closes the conditional block.
- Everything between the opening and closing tags only appears if dealname has a value.
Examples for in tables
- If the dealname property exists and has a value, it shows the deal’s name followed by its description.
- If dealname is blank, nothing is shown and the table box will be left empty
- {% block if object.dealname %}: “Only show what’s inside this block if the dealname exists (is not blank).”
- {{ object.dealname }} - {{ object.description }}: “Display the deal’s name, then a dash, then the deal’s description.”
- {% end block %}: “That’s the end of the conditional block — stop checking now.”
Examples for deleting images, tables and text boxes
- The code is setup so If the token contains no value, delete everything between
{% block if object.hs_all_collaborator_owner_ids %} and {% end block %} - If the token does contain a value, then keep everything in between.
- In this case the property for ‘Deal Collaborator’ is empty so when you run it through DocMergy there will be nothing shown