# Programmable Email Beta - escaped HTML bug

**URL:** <https://community.hubspot.com/t/programmable-email-beta-escaped-html-bug/80900>\
**Category:** Email Marketing Tool\
**Tags:** templates, contacts, content, marketing-email, enterprise\
**Created:** [May 10, 2023, 9:02am UTC](https://community.hubspot.com/t/programmable-email-beta-escaped-html-bug/80900 "2023-05-10T09:02:08Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ESmith77](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@ESmith77](https://community.hubspot.com/u/ESmith77)\
**Post date:** [May 10, 2023, 9:02am UTC](https://community.hubspot.com/t/programmable-email-beta-escaped-html-bug/80900/1 "2023-05-10T09:02:08Z")

</div>

Hi all. Having some issues with the new programmable email templates. According to this info ([Create emails with programmable content - HubSpot docs](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:

```lia-code-sample
{% 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:

```lia-code-sample
{% 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?

---

<div class="post-metadata">

**Author:** ![danmoyle](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/danmoyle/32/91166_2.png) [@danmoyle](https://community.hubspot.com/u/danmoyle)\
**Post date:** [May 10, 2023, 5:56pm UTC](https://community.hubspot.com/t/programmable-email-beta-escaped-html-bug/80900/2 "2023-05-10T17:56:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jolle](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jolle/32/44040_2.png) [@jolle](https://community.hubspot.com/u/jolle)\
**Post date:** [May 10, 2023, 6:05pm UTC](https://community.hubspot.com/t/programmable-email-beta-escaped-html-bug/80900/3 "2023-05-10T18:05:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jnix284](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jnix284/32/29_2.png) [@jnix284](https://community.hubspot.com/u/jnix284)\
**Post date:** [May 10, 2023, 11:59pm UTC](https://community.hubspot.com/t/programmable-email-beta-escaped-html-bug/80900/4 "2023-05-10T23:59:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ESmith77](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@ESmith77](https://community.hubspot.com/u/ESmith77)\
**Post date:** [May 11, 2023, 9:25am UTC](https://community.hubspot.com/t/programmable-email-beta-escaped-html-bug/80900/5 "2023-05-11T09:25:08Z")

</div>

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#](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:

```lia-code-sample
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!**

---

<div class="post-metadata">

**Author:** ![MiaSrebrnjak](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/miasrebrnjak/32/10_2.png) [@MiaSrebrnjak](https://community.hubspot.com/u/MiaSrebrnjak)\
**Post date:** [May 11, 2023, 2:07pm UTC](https://community.hubspot.com/t/programmable-email-beta-escaped-html-bug/80900/6 "2023-05-11T14:07:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ESmith77](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@ESmith77](https://community.hubspot.com/u/ESmith77)\
**Post date:** [May 11, 2023, 2:36pm UTC](https://community.hubspot.com/t/programmable-email-beta-escaped-html-bug/80900/7 "2023-05-11T14:36:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ndwilliams3](https://avatars.discourse-cdn.com/v4/letter/n/c4cdca/32.png) [@ndwilliams3](https://community.hubspot.com/u/ndwilliams3)\
**Post date:** [May 19, 2023, 9:05pm UTC](https://community.hubspot.com/t/programmable-email-beta-escaped-html-bug/80900/8 "2023-05-19T21:05:57Z")

</div>

@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?

---

<div class="post-metadata">

**Author:** ![ESmith77](https://avatars.discourse-cdn.com/v4/letter/e/c6cbf5/32.png) [@ESmith77](https://community.hubspot.com/u/ESmith77)\
**Post date:** [May 23, 2023, 8:16am UTC](https://community.hubspot.com/t/programmable-email-beta-escaped-html-bug/80900/9 "2023-05-23T08:16:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ndwilliams3](https://avatars.discourse-cdn.com/v4/letter/n/c4cdca/32.png) [@ndwilliams3](https://community.hubspot.com/u/ndwilliams3)\
**Post date:** [May 23, 2023, 4:12pm UTC](https://community.hubspot.com/t/programmable-email-beta-escaped-html-bug/80900/10 "2023-05-23T16:12:19Z")

</div>

@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.

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

```

---

<div class="post-metadata">

**Author:** ![ndwilliams3](https://avatars.discourse-cdn.com/v4/letter/n/c4cdca/32.png) [@ndwilliams3](https://community.hubspot.com/u/ndwilliams3)\
**Post date:** [May 19, 2023, 9:24pm UTC](https://community.hubspot.com/t/programmable-email-beta-escaped-html-bug/80900/11 "2023-05-19T21:24:00Z")

</div>

@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?

> **[Create emails with programmable content - HubSpot docs](https://developers.hubspot.com/docs/cms/start-building/features/data-driven-content/emails-with-programmable-content)**

> **[Create programmable emails](https://knowledge.hubspot.com/marketing-email/create-programmable-emails)**
>
> Learn how to create programmable emails in HubSpot (BETA).
