Recommendations Designs - Escaping Content

Avatar

Avatar
Validate 1
Level 2
neilh83114327
Level 2

Likes

10 likes

Total Posts

7 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 2
neilh83114327
Level 2

Likes

10 likes

Total Posts

7 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
neilh83114327
Level 2

30-11-2017

Do Recommendations Designs support escaping of characters for formats they need to be delivered in? This seems critical to producing valid syntax in Design results. Examples:

  • JavaScript needs escaped quotes (\" and \'): entityTitle = "HD 48\" TV & speakers"
  • HTML attributes need HTML encoding &quot for double quotes etc: <img alt="HD 48&quot; TV &amp; speakers" ...
  • HTML requires html encoding: HD 48" TV &amp; speakers

The documentation says that Designs use Apache "Velocity Version 1.5 with no additional tools or libraries". However, I swear I recall seeing an article somewhere on how to escape quotes for JavaScript in the Velocity used in Recommendations-- but I can't find it again!  I checked for Velocity's EscapeTool library but it is not installed.

Thank you for your assistance!

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 2
neilh83114327
Level 2

Likes

10 likes

Total Posts

7 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 2
neilh83114327
Level 2

Likes

10 likes

Total Posts

7 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
neilh83114327
Level 2

05-01-2018

That article talks about escaping reserved characters ($) in a design template (Velocity).  My question was around escaping the value of the entity's output.  In particular, double quotes in content cause problems when trying to generate JSON syntax or HTML attribute syntax.

My solution: Without the ability escape in Velocity, I escape the content before uploading in the product feed.  A good compromise for most scenarios is to html encode double quotes to &quot; .  In practice that is working well.

In most cases, the end result will be inserting it into an HTML document (web page, email, etc) where it will work properly.  Should you ever need plain text, you'll need to decode html.

Answers (1)

Answers (1)

Avatar

Avatar
Validate 250
Employee
Amelia_Waliany
Employee

Likes

191 likes

Total Posts

452 posts

Correct reply

73 solutions
Top badges earned
Validate 250
Validate 100
Validate 50
Validate 25
Validate 10
View profile

Avatar
Validate 250
Employee
Amelia_Waliany
Employee

Likes

191 likes

Total Posts

452 posts

Correct reply

73 solutions
Top badges earned
Validate 250
Validate 100
Validate 50
Validate 25
Validate 10
View profile
Amelia_Waliany
Employee

18-12-2017

Hi there and thanks for your question! If you need to escape something you just need to add a backslash in front of whatever needs to be escaped. Check out the article on Customizing a Template in the Adobe Target Product Documentation for more info, and feel free to reach out here if you have any additional questions. Hope this helps!