Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Encoding url in sightly

Avatar

Level 4

Hi All,

Some of documents url have space in them, I want to encode them in sightly it is possible to do so.

I have tried using context uri but that also did not worked

${properties.jcr:title @ context='uri'} 
1 Accepted Solution

Avatar

Correct answer by
Level 10

You can use JavaScript Use API,, assume this code is present in file name first.js

"use strict"; use(function () { eurl = encodeURI(this.url); return eurl; });

and call this via 

<sly data-sly-use.info="${'first.js' @ url=properties.jcr:title}"> <h1> ${info} </h1> </sly>

View solution in original post

4 Replies

Avatar

Level 10

Are you documents present in AEM? If yes, I guess you wont have space in url as they will get replced by hypen '-'

You are you showing just document name  or make hyper links on them? let me know...

Avatar

Level 4

These documents are not present inside AEM

Avatar

Correct answer by
Level 10

You can use JavaScript Use API,, assume this code is present in file name first.js

"use strict"; use(function () { eurl = encodeURI(this.url); return eurl; });

and call this via 

<sly data-sly-use.info="${'first.js' @ url=properties.jcr:title}"> <h1> ${info} </h1> </sly>

Avatar

Level 4

Thank you, Yes I can do something like this.