Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Sightly Join with White spaces

Avatar

Level 6

Hi,

I need to join a string array with whitespaces. 

I'm doing that this way:

${item.tagNames @ join=' '}

But when it is printing it this way in the HTML:

tuna sushitypes

Is there any way to do that?

Thaks

1 Accepted Solution

Avatar

Correct answer by
Level 6

I found a way:

1. Store it using data-sly-test

<div data-sly-test.joined="${item.tagNames @ join=' '}" data-sly-unwrap />

2. Use the context='unsafe'

${joined @context='unsafe'}

Thanks

View solution in original post

2 Replies

Avatar

Correct answer by
Level 6

I found a way:

1. Store it using data-sly-test

<div data-sly-test.joined="${item.tagNames @ join=' '}" data-sly-unwrap />

2. Use the context='unsafe'

${joined @context='unsafe'}

Thanks

Avatar

Employee

You can also combine options, like @ join=' ', content = 'HTML'

Try to avoid the 'unsafe' context, the first output you had was correct, because the space was escaped for XSS.

In this doc-link you can find more @ context options: http://docs.adobe.com/docs/en/aem/6-0/develop/sightly.html