If Statements for Dummies (me)

Hi there,
I wanted to reach out to see if anyone could offer any information on setting up ‘if statements’ for email templates?
I’m looking to migrate the ones I currently have in Outreach, but I understand HubSpot requires the use of HubL. Currently, we use them in Outreach mostly to change dates where necessary (eg if Friday, print ‘have a great weekend’).

For full transparency, I am a total novice in this space and have found myself down something of a HubL Syntax rabbit hole, also worth noting that I did not set up the ones in Outreach either.
Is there any introductory tips anyone can offer on this? I’ve already read the explainer here, but unfortunately feel none the wiser. > If statements - HubSpot docs

Any help would be hugely appreciated.

Many thanks,

Lewis

Hey @lewisgray ,
The answer here depends on how all you’re wanting to use the if statement. In email Hubspot does not currently support the use of contact properties or information generated by a transactional email within if statements. I also don’t think you’re able to use them within rich text modules.
The only use case really available for if statements in email would be in using custom modules to change content. Which this you can definitely do for changing text based on the day.

Here’s documentation on creating and using custom modules :

And the following is code that would change the text based on if it’s Friday using the datetimeformat function:

{% if local_dt|datetimeformat('%A') == 'Friday' %}
 Have a great weekend!
{% else %}
 Other Text
{% endif %}

If you’re ever wanting to use if statements for transactional emails or contact properties I’d suggest checking out this Ideas post, upvoting it, and voicing your use case for needing this functionality.
https://community.hubspot.com/t5/HubSpot-Ideas/if-statements-in-email-templates/idi-p/282907