Email Marketing Tool

JuliaVallina
Member

Programmable email: Bug when in macros when passing contact property

SOLVE

Hello, 

 

We have a programmable email that we send every month and we just found out that there is a bug in it. We are seeing some behaviour that was not happening the previews months.

 

In an email module, when using a macro that receives a contact property, the output is treated as a string instead of HTML so in the final email we are seeing HTML tags.

 

This is the minimun code to reproduce the error.

For a given contact with the property `monthly_consumption` set to '{"test":"anything"}'

 

{% set data = contact.monthly_consumption|fromjson %}

{% macro test(user_property) %}
<span>Print {{user_property}}</span>
{% endmacro %}
{{test(data.test)}}

 

It returns a string, so in the final email this is what it is displayed instead of just Print anything. The <span> tags are visible. 

2.png

 

If we pass a static param to the macro, it works as expected. 

For example, this works {{test("anything")}}

and even this, with a static json defined

{% set data = '{"test":"anything"}'|fromjson %}

{% macro test(user_property) %}
<span>Print {{user_property}}</span>
{% endmacro %}
{{test(data.test)}}

 

I could use some help with this.

Thank you

0 Upvotes
1 Accepted solution
PamCotton
Solution
Community Manager
Community Manager

Programmable email: Bug when in macros when passing contact property

SOLVE

Hey @JuliaVallina, thank you for reaching out and providing detailed information about the issue you're experiencing with your programmable email. 

 

I understand how frustrating it can be when previously working functionality starts to behave unexpectedly.

Based on your description, it seems the issue arises when the macro receives a contact property, resulting in the HTML tags being displayed as plain text in the final email.

 

One way to address this issue is to ensure that the content passed to the macro is not being treated as plain text. You can try using the |safe filter, which marks a string as safe for HTML output.

 

To our top experts @Anton and @franksteiner79 do you have any recommendations for @JuliaVallina matter?

 

Thank you,

 

Pam

Você sabia que a Comunidade está disponível em outros idiomas?
Participe de conversas regionais, alterando suas configurações de idioma !


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




View solution in original post

0 Upvotes
2 Replies 2
PamCotton
Solution
Community Manager
Community Manager

Programmable email: Bug when in macros when passing contact property

SOLVE

Hey @JuliaVallina, thank you for reaching out and providing detailed information about the issue you're experiencing with your programmable email. 

 

I understand how frustrating it can be when previously working functionality starts to behave unexpectedly.

Based on your description, it seems the issue arises when the macro receives a contact property, resulting in the HTML tags being displayed as plain text in the final email.

 

One way to address this issue is to ensure that the content passed to the macro is not being treated as plain text. You can try using the |safe filter, which marks a string as safe for HTML output.

 

To our top experts @Anton and @franksteiner79 do you have any recommendations for @JuliaVallina matter?

 

Thank you,

 

Pam

Você sabia que a Comunidade está disponível em outros idiomas?
Participe de conversas regionais, alterando suas configurações de idioma !


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




0 Upvotes
JuliaVallina
Member

Programmable email: Bug when in macros when passing contact property

SOLVE

It worked 🙂 I added |safe to the macro call and the <span> now renders as expected.

Thank you very much!

Have a nice day

 

0 Upvotes