Sightly data-sly-test with conditional operator | Community
Skip to main content
tc94524330
Level 3
July 5, 2016
Solved

Sightly data-sly-test with conditional operator

  • July 5, 2016
  • 1 reply
  • 7441 views

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?

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 Tuhin_Ghosh

Try the below, this should work.

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

//some code here

</sly>

 

Thanks

Tuhin

1 reply

Tuhin_Ghosh
Tuhin_GhoshAccepted solution
Level 8
July 5, 2016

Try the below, this should work.

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

//some code here

</sly>

 

Thanks

Tuhin