Displaying literal curly braces {{ }} in LPs and emails

SanfordWhiteman
Level 10 - Community Moderator
Level 10 - Community Moderator

Marketo’s content processing can be, in a word, greedy.

 

When it detects Mustache-style double-curly-brace notation — like {{lead.Some Field}} — that either

 

(1) matches a known field (in the case of a {{lead.token}}), or

(2) simply looks like like a token (in the case of a {{my.token}})

 

the app grabs ownership and outputs the value of the underlying field/token.

 

And if it detects a {{lead.token}}-like sequence that doesn’t match a known field, it’ll throw a validation error.

 

Both cases are problematic if you meant to output literal double curly braces in the body of a page or email.

 

(If you’re wondering why you’d want literal content like “{{lead.Some Field}}” on a page, well, consider that software companies use Marketo and they may want to show sample code. And in general, no characters should ever be completely forbidden — that’s my take!)

 

The most obvious way to escape token-lookalike expressions doesn’t work. HTML entity-encoding in the Rich Text editor...

 

{{lead.Email Address;}}

 

 

... doesn’t take because the entities get converted back to the {{ }} characters when you hit Save. So effectively you haven’t done anything different.

 

It’s still possible, though.

 

In HTML
In both LPs and HTML emails, just wrap one of the curly braces in a <span>:

 

<span>{</span>{lead.Email Address}<span>}</span>

 

 

Now Marketo won’t see the characters {{ right next to each other, and you’ll get the literal “{{lead.Email Address}}” output you want.

 

In Text
In the Text part of an email, you can use — why do all of my posts have something to do with Velocity? — a Velocity {{my.token}}. Thanks to order-of-operations, a one-liner like this will work:

 

{{lead.Email Address}}

 

 

(See also my post Even when Velocity isn’t doing anything, it’s doing something good.)

 



Notes

  • The goal is to have the text be correct when copied-and-pasted. So putting Unicode Word-Joiner &#8288; characters in-between curly braces wouldn’t cut it. (Though that trick is certainly useful in other cases.)
  • You might wonder why I didn’t suggest a Text {{my.token}} instead of VTL, e.g.:5ecd7eb49297cd00454defcc_curly_esc

     

My reasoning is that Lead-Tokens-in-Text-My-Tokens are currently not supported (so the literal value will be output) but there’s some non-zero chance that might change, so better to not rely on it. In contrast, the Velocity world wont suddenly start parsing non-Velocity notation.

2023
5
5 Comments
Lara_Krefski
Level 2

I tried doing what you said with the span tags in my email around one of the curly braces <span>{</span>{ but it did not work. Marketo still gave this  "Error approving 2023-03-PP-EM-7131-Release-Notes.EM1 - New Template — {{pp_api_base_url}} : Token is not a valid token format"

SanfordWhiteman
Level 10 - Community Moderator

Can you please show a screenshot of that part of the email? I'm not aware of a regression that would stop method from working.

Lara_Krefski
Level 2

Here are the screenshots of the code and the email.

 code.pngemail.png

SanfordWhiteman
Level 10 - Community Moderator

Darn it. This method did stop working after some Marketo upgrade. But this works:

SanfordWhiteman_0-1677725210597.png

With 2 Text {{my.tokens}}.

Lara_Krefski
Level 2

Thank you for your help.