Email Marketing Tool

ESmith77
Participant

Programmable Email Beta - escaped HTML bug

SOLVE

Hi all. Having some issues with the new programmable email templates. According to this info (https://developers.hubspot.com/docs/cms/guides/email/hubdb-crm-objects) I should be able to query HubDB using contact properties.

 

What I’m trying to do is render some HTML that is stored in HubDB. The tutorial I linked to says that I should be able to pull data from HubDB into a drag and drop template, or a coded email template.

 

If I use this code, the HTML tags are escaped when the email renders, resulting in the code being displayed as plain text:

 

{% set template = hubdb_table_rows(1234567, "email_name=welcome&site_domain="~contact.site_domain) %}

{{ template[0].html }} 

 

However, when I specify the full query without using any contact properties, the HTML is not escaped and is rendered directly within the email template as expected:

 

{% set template = hubdb_table_rows(1234567, "email_name=welcome&site_domain=https://www.sitename.com") %}

{{ template[0].html }} 

 

I see no reason why we should expect this to render the output differently depending on how the query is structured.This has to be a bug, right?

1 Accepted solution
ESmith77
Solution
Participant

Programmable Email Beta - escaped HTML bug

SOLVE

UPDATE: I spoke to customer support and was given access to this document which outlines some limitations of the programmable email beta: https://docs.google.com/document/d/1BxxVwSgBcPZ1GdmaaNcoj2fgKSrM2ORZA_fiX7cHER8/edit#

There is a section in there about using HTML from within the contact properties, which I figured would probably affect HubDB in the same way:

 

 

HTML that is included in a contact property will be escaped and rendered as a string instead of HTML. This is due to escaping being enabled by default within the new renderer. To render HTML in contact properties use the safe filter

{{ contact.property_with_html | safe }}

 

 

For anyone else who stumbles across this issue, using the 'safe' filter will allow your HTML to render, however any HubL code within that HTML will no longer work.

 

For me this is still a nuisance, as simply hard-coduing the HubDB query would allow both my HTML and HubL to render properly, but unfortunately that isn't an option, so I'm left to choose between HTML or HubL. I hope this is remedied soon.

 

Update 2: HubL code does actually render in test emails, just not in previews. This is effectively solved!

View solution in original post

10 Replies 10
ndwilliams3
Key Advisor

Programmable Email Beta - escaped HTML bug

SOLVE

@MiaSrebrnjak, There's some critial information in the document provided to @ESmith77. I'm surprised there isn't a reference to these limitations in any of the docs. Can you have the appropiate team update the docs with the limitations? 

https://developers.hubspot.com/docs/cms/guides/email/hubdb-crm-objects

https://knowledge.hubspot.com/email/create-programmable-emails

 

ndwilliams3
Key Advisor

Programmable Email Beta - escaped HTML bug

SOLVE

@ESmith77 

The document was extremely helpful. Had issues with "Reusing variable names for results of HubDB or Custom Objects queries." Wish I had found it 2 hours ago?

0 Upvotes
ESmith77
Participant

Programmable Email Beta - escaped HTML bug

SOLVE

Seriously. I was stuck for a couple of days on this issue and I had it solved within a minute of looking at that doc. I've also asked them to sort out their documentation. This is a common issue with Hubspot: Incomplete, vague, or inaccurate documentation.

0 Upvotes
ndwilliams3
Key Advisor

Programmable Email Beta - escaped HTML bug

SOLVE

@ESmith77 ,

 

Same here! Strugling with stange behavior that all makes sense now after looking at that document. From my testing, if you are using contact properties in your logic you can't use more than a single instance of a custom module. Even different custom modules that share a common field name results in the second module field showing the value from the first module. Having to re-think the entire setup.

 

FYI, I did figure out how to get a decent preview without HUBL code. This snippet allows you to add a block with static/default content to show in the editor and default preview. 

 

{% if (is_in_previewer and !buffer_mode.isPreProcessedTemplate) or is_in_editor %}
preview content
{% else %}
contact preview and live send content
{% endif %}

 

0 Upvotes
ESmith77
Solution
Participant

Programmable Email Beta - escaped HTML bug

SOLVE

UPDATE: I spoke to customer support and was given access to this document which outlines some limitations of the programmable email beta: https://docs.google.com/document/d/1BxxVwSgBcPZ1GdmaaNcoj2fgKSrM2ORZA_fiX7cHER8/edit#

There is a section in there about using HTML from within the contact properties, which I figured would probably affect HubDB in the same way:

 

 

HTML that is included in a contact property will be escaped and rendered as a string instead of HTML. This is due to escaping being enabled by default within the new renderer. To render HTML in contact properties use the safe filter

{{ contact.property_with_html | safe }}

 

 

For anyone else who stumbles across this issue, using the 'safe' filter will allow your HTML to render, however any HubL code within that HTML will no longer work.

 

For me this is still a nuisance, as simply hard-coduing the HubDB query would allow both my HTML and HubL to render properly, but unfortunately that isn't an option, so I'm left to choose between HTML or HubL. I hope this is remedied soon.

 

Update 2: HubL code does actually render in test emails, just not in previews. This is effectively solved!

MiaSrebrnjak
Community Manager
Community Manager

Programmable Email Beta - escaped HTML bug

SOLVE

Thank you for sharing @ESmith77! This is very helpful! 

I realize that this isn't a solution for your specific use case, but I'll still go ahead and accept your answer as a solution, as this increases the visibility of your post in the Community and reaches more users who might be experiencing a similar issue.

 

I hope that's okay! If you'd prefer to leave this unsolved, please let me know!

 

Thanks, 

Mia, Community team 




Wusstest du, dass es auch eine DACH-Community gibt?
Nimm an regionalen Unterhaltungen teil, indem du deine Spracheinstellungen änderst


Did you know that the Community is available in other languages?
Join regional conversations by
changing your language settings


ESmith77
Participant

Programmable Email Beta - escaped HTML bug

SOLVE

Hi Mia, it turns out this is actually a solution after all. The contact data doesn't render in the preview, but it does render in test emails!
Thanks

danmoyle
Most Valuable Member | Elite Partner
Most Valuable Member | Elite Partner

Programmable Email Beta - escaped HTML bug

SOLVE

@jolle @Jnix284 do either of you use programmable emails? Do you have a tip for @ESmith77 ? 

 

Did my answer help? Please "mark as a solution" to help others find answers. Plus I really appreciate it!


Dan Moyle

HubSpot Advisor

LearningOps | Impulse Creative

emailAddress
dan@impulsecreative.com
website
https://impulsecreative.com/
jolle
Recognized Expert | Partner
Recognized Expert | Partner

Programmable Email Beta - escaped HTML bug

SOLVE

@danmoyle thanks for the tag! Sadly, I have not worked with these before. I'm wondering if @christopher-RVO has any thoughts here?

Jacob Olle

Marketing Operations Manager

HubSpot Certified Trainer

Create Your Own Free Signature
Jnix284
Hall of Famer

Programmable Email Beta - escaped HTML bug

SOLVE

@danmoyle I also haven't worked with programmable emails with the new features or HubDB, maybe @Anton can help?


If my reply answered your question please mark it as a solution to make it easier for others to find.


Jennifer Nixon