Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Slightly- test if path does not contain //

NitroHazeDev
Level 7
Level 7

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
kishorekumar14
Correct answer by
Level 9
Level 9

Hi @NitroHazeDev ,

 

Please try like below

 

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

View solution in original post

5 Replies
Asutosh_Jena_
Community Advisor
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!

kishorekumar14
Level 9
Level 9

Hi @NitroHazeDev ,

 

Please try like below.

 

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

Thanks @Asutosh_Jena_  and @kishorekumar14 . 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'}

 

kishorekumar14
Correct answer by
Level 9
Level 9

Hi @NitroHazeDev ,

 

Please try like below

 

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

View solution in original post