Conversion of & to & | Community
Skip to main content
tabassump428879
Level 2
Oct 31, 2017 7:01 AM UTC
Solved

Conversion of & to &

Hi,

We are using HTL for component development.

The title field is populated dynamically and contains the character '&': example : Audio & Video.

When we "View page source"  & is converted to & due to html encoding. example : Audio & Video

We want to avoid this encoding and & should be displayed as & itself.

context="unsafe" and context="scriptToken" avoids encoding and helps to resolve the issue, but these are not recommended and accepted by the client.

We have tried using StringUtils,encode(), StringUtils.escape() methods but it did not work as expected

Are there any other alternatives through which this can be achieved. Any pointers would help

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
manoj_devapath
manoj_devapathAccepted solution
Level 5
Oct 31, 2017 12:38 PM UTC

use <div>${properties.text @ context='html'}</div>

context='html' will convert &amp; to & on page

4 replies

manoj_devapath
manoj_devapathAccepted solution
Level 5
Oct 31, 2017 12:38 PM UTC

use <div>${properties.text @ context='html'}</div>

context='html' will convert &amp; to & on page

Translate
Feike_Visser1
Employee
Oct 31, 2017 11:17 AM UTC

This is what I would expect.

Translate
tabassump428879
Level 2
Oct 31, 2017 11:15 AM UTC

Hi Feike,

On the page the value is displayed correctly.

Its only when we try viewing page source code it is converted to '&amp;'

We want '&' to display as '&' only when we view page source as well.

Translate
Feike_Visser1
Employee
Oct 31, 2017 8:06 AM UTC

Normally character like & < > are always encoded, why is this not the case at your components?

Translate