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

Slightly- test if path does not contain //

Avatar

Level 10

All, silly question but does anyone know how I could test if path does not contain // 

 

I tried strings other than // and it worked but not this . I used “in”

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @NitroHazeDev ,

 

Please try like below

 

${!('//' in '//content/abc')}

View solution in original post

5 Replies

Avatar

Community Advisor

Hi @NitroHazeDev 

 

Since version 1.4, you can use in relational operator: https://github.com/adobe/htl-spec/blob/master/SPECIFICATION.md#1143-relational-operators

 

${'//' in '//content/abc'} <!--/* returns true */-->
${'//' in '/content/abc'} <!--/* returns false */-->

 

Hope this helps!

Thanks!

Avatar

Community Advisor

Hi @NitroHazeDev ,

 

Please try like below.

 

<sly data-sly-test.isDoubleSlashContain="${'//' in '/content//test'}"/>
<div data-sly-test="${!isDoubleSlashContain}">
  //your code
</div>

Avatar

Level 10

Thanks @Asutosh_Jena_  and @Kishore_Kumar_ . I tried the in operator with the //, worked great but was trying to use a ! operator with it, as below.. what do you think i could be missing? I wanted a single line check rather than assigning to a variable and checking

${!'//' in '//content/abc'}

 

Avatar

Correct answer by
Community Advisor

Hi @NitroHazeDev ,

 

Please try like below

 

${!('//' in '//content/abc')}