Slightly- test if path does not contain // | Community
Skip to main content
Level 9
November 9, 2021
Solved

Slightly- test if path does not contain //

  • November 9, 2021
  • 4 replies
  • 1176 views

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”

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Kishore_Kumar_

Hi @nitrohazedev ,

 

Please try like below

 

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

4 replies

Asutosh_Jena_
Community Advisor
Community Advisor
November 9, 2021

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!

Kishore_Kumar_
Level 9
November 9, 2021

Hi @nitrohazedev ,

 

Please try like below.

 

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

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'}

 

Kishore_Kumar_
Kishore_Kumar_Accepted solution
Level 9
November 9, 2021

Hi @nitrohazedev ,

 

Please try like below

 

${!('//' in '//content/abc')}
Level 9
November 9, 2021

Thank you @kishore_kumar_ . Much appreciated. That helped