Hubl and if statement has content

Hi, all!

Coming from a Freemarker environment and cannot find this simple query. We use variations of it in multiple scenarios.
The Freemarker uses the condition "

has_content

" -- any content in the specified field.

[if Profile.FirstName?has_content]${Profile.FirstName},[#else]Hi![/#if]

If the field does NOT have content, then remove spacing and display a different message.

Hey, @MMcRae :waving_hand: Welcome to our community! Have you already looked into the Create programmable emails option? This enables a lot more HubL personalization options for emails.

Best,

Jaycee

Thanks for the info, but from my historic usage of other ESPs, this is a simple query.
It shouldn’t require programmable templates unless that’s HubSpot’s only way to handle a basic if/else statement looking for content in a property.

I believe you received the response you did because you were giving an example of “code” and you are in the developer section of this site. If you would have asked this question in more of the marketing focused area, they likely would have given you a differnet answer.
You can do this when editing the pages -- they are “personalization tokens” and you can inject them wherever you’d like.
Example screenshot | docs
Each property can be set up with a default value -- that way they show the default value instead of a blank item.

Hi @MMcRae

In HubSpot, you can use HubL, its Jinja-based templating language, for conditional content rendering. While HubL lacks a direct equivalent to Freemarker, it supports if statements to check for the existence of non-empty values.
Here’s how to write your example in HubL:

{% if contact.firstname %}
 {{ contact.firstname }},
{% else %}
 Hi!
{% endif %}

I hope this will help you out. Please mark it as Solution Accepted and upvote to help another Community member.
Thanks!

This did not work within a non-programmable email. Thank you for trying.

Thank you for responding, Nick and others:
I chose the “developer” side as it is related to Hubl and Hubspot is different from SalesForce Marketing Cloud which uses Ampscript or another ESP which uses Freemarker.
The personalization token code within the “marketing” section of Hubspot does not resolve this issue.
It that you have to use programmable templates as noted from Jaycee’s comment and from what testing I’ve done.
In other ESPs, this task is at the email-build level. I’ve tried finding documentation from others who have migrated from SalesForce Marketing Cloud, but have come up empty. Would appreciate any help if anyone knows of any.