How to escape single quote and double quote when programmatically set default value of a token
Hello Team,
I have a question. We use API /content/api/v2/templates to push marketing emails to Hubspot. And when constructing the email, We replace some content with tokens to load personalized content. We inject the token using {{ personalization_token('${hubObjectType}.${p13nToken}', '${originalText.replace(/\n/g, '<br>').replace(/(['"])/g, '\\$1').trim()}')') }}, so that the originalText will display when the token isn’t available. But it seems HubSpot can’t correctly recognize the token when originalText contains single quotes (') or double quotes (''). We’ve tried some escape methods (e.g., using HTML codes for ‘ and ", javascript string replacement), but none work in all cases. Is there a reliable way to safely escape single quotes and double quotes for this case? Thank you.
I'd like to invite a couple of subject matter experts to this conversation: Hi @Indra, @Syeda_Fatima and @stefen do you have suggestions to help @YQin, please?
How to escape single quote and double quote when programmatically set default value of a token
Hi @Indra@stefen and others, wondering if you have any tips here?
Basically, we cannot include an apostrophe or quotation marks in the default value for personalization_token when pushing the source content using the `/content/api/v2/templates` endpoint.
It seems there should be a way to escape these characters.