Hi,
I am working on an email templating project in which I am trying to set a variable value in Personalization Block through Embedded JavaScript(EJS) Syntax.
The issue I am facing is that I'm unable to set the value in variable. Upon rendering it is simply displaying the text. For example:
Code:
<% var subject = %> <?= cms.subject ?>
Rendered in Personalization Block
Scenario:
I am working with Contentful(Headless CMS) which is linked with Adobe Campaign. I upload the HTML with Embedded JavaScript (EJS) template on Contentful and from there I push the code to Adobe Campaign Personalization Block. Once the code is rendered so it looks something like the above screenshot as shown.
I tried using the below code but it doesn't work
<% var subject = "<?= cms.subject ?>" %>
because it throws an error, when I upload the document on Contentful, by stating that it cannot find the closing tag "<?". So somehow I need to achieve this by concatenation or I would say by extracting input element attribute value like below, so I can easily assign the value in variable.
<input id="emailInput" value="<?= cms.subject ?>" type="hidden" ></input>
Can anyone help to set this value ?
Thank you
Solved! Go to Solution.
Views
Replies
Total Likes
I was able to resolve it by converting the constructs into HTML Entities. For example:
<% var subject = "<?= cms.subject ?>" %>
is equal to:
<% var subject ="<?= cms.subject ?>"; %>
By converting the syntax, I was able to pass the syntax through Contentful and then syntax was successfully rendered in Adobe.
Views
Replies
Total Likes
Hi @Amine_Abedour,
The "cms.subject" can only work with EJS syntax Like:
<?= cms.subject ?>
only then it can print the output otherwise in Personalized Block it will give an error that "cms" is undefined.
Views
Replies
Total Likes
I was able to resolve it by converting the constructs into HTML Entities. For example:
<% var subject = "<?= cms.subject ?>" %>
is equal to:
<% var subject ="<?= cms.subject ?>"; %>
By converting the syntax, I was able to pass the syntax through Contentful and then syntax was successfully rendered in Adobe.
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies