APIs & Integrations

Not applicable

Using Conditional Rendering(Hubl) in Email Template For Single Send API

Hey,

I was trying to use hubl conditional rendering (if) as part of an html email template for single send API.

If statements

HubL uses if statements to help define the logic of a template. The syntax of HubL if statements is very similar to conditional logic in Python. If statements are wrapped in statement delimiters, starting with an opening if statement and ending with...


But it seems that when sending the email, the condition ignores the value of the variable.
Someone knows if it is possible and how?

Thanks

0 Upvotes
3 Replies 3
mgoswick
Contributor

Using Conditional Rendering(Hubl) in Email Template For Single Send API

This is currently not possible in HubSpot because of how the order of rendering occurs. When building the content in the emails, HubSpot compiles the HubL before using any contact or company variables. Once the document is compiled, HubSpot fills in any missing tokens. As such, when it reaches the if statement, the statement will evaluate as if the condition variable is null. 

 

You can find more information below about HubL if statements and limitations

https://designers.hubspot.com/docs/hubl/if-statements

0 Upvotes
BiG
Contributor

Using Conditional Rendering(Hubl) in Email Template For Single Send API

Yes, as said before, this is currently not implemented.

 

We added the query to have HUBL if's for emails to the ideas here in the forum.

 

If you agree, please support this idea which queries for if statements in HUBL for emails:
https://community.hubspot.com/t5/HubSpot-Ideas/if-statements-in-email-templates/idi-p/282907

0 Upvotes
AndrewEnodo
Member

Using Conditional Rendering(Hubl) in Email Template For Single Send API

Hello,

I am following up on this with the same issue. We are trying to build an email payment receipt and with it a field for promotional discount. I am trying to use Hubl to place an if statement to hide or show that portion of the email. It doesn’t seem to pick up the value of the variable.

Please advise. Thanks.

0 Upvotes