Expand my Community achievements bar.

SOLVED

Sightly data-sly-test with conditional operator

Avatar

Level 4

Hi,

I am new to sightly. I am trying to write data-sly-test statement for JPEG and PNG like this:

 <sly data-sly-test="${properties.assetFormat==('image/png' || 'image/jpeg')}">

//some code here

</sly>

With this statement it is only displaying images with dc:format image/png not for images with dc:format image/jpeg. If i reverse the order, then it only looks for image/jpeg.  I tried various different approaches but nothing worked.

Does any one have any suggestion on how to use OR properly with data-sly-test?

1 Accepted Solution

Avatar

Correct answer by
Level 7

Try the below, this should work.

<sly data-sly-test="${properties.assetFormat == 'image/png' || properties.assetFormat == 'image/jpeg'}">

//some code here

</sly>

 

Thanks

Tuhin

View solution in original post

1 Reply

Avatar

Correct answer by
Level 7

Try the below, this should work.

<sly data-sly-test="${properties.assetFormat == 'image/png' || properties.assetFormat == 'image/jpeg'}">

//some code here

</sly>

 

Thanks

Tuhin