Highlighted

AEM6.3 equals compare on sightly template

elizabethp60981

28-02-2018

Hi,

I am reading a java object on an sightly template and I have a js server-side.

I am trying to compare a value from this js server-side with a value of my java list.

When I print the compare on my page it evaluates as true, but when I put this same code inside a data-sly-test, the value seems not true as the code inside is not executed, but I am printing out this condition and is true. My code:

<sly data-sly-use.data="${'xxx.xxxx.xxxx.xxxxxx.core.access.resource.ContingencyAccess' @ market=util.market}" data-sly-list.item="${data.contingencyList}" data-sly-test.="${util.month_back[0].month == item.month}">

Is not posible to do this kind of compare inside sightly code?

How should I deal with it?

Thank you very much in advance!

Replies

Highlighted

smacdonald2008

28-02-2018

think of HTL as the View and Java as setting the data to be displayed. You can control the data much better in Java and place the data in collections that the HTL can Display.

Highlighted

elizabethp60981

28-02-2018

Hi Scott,

Thank you for your reply,

we are doing our logic on java, but it has some validations that I have to do on layout, like if  the item on my list is this one I show on this way and if returns that I show on that way.

I am trying to think some workaround to do this, but I was wondering if is this not really posible to do on sightly.

Thank you once more

Highlighted

Vijayalakshmi_S

MVP

28-02-2018

HI Elizabeth,

From the snippet pasted in your original post, could observe a "." after data-sly-test. Not sure if it is a typo here or in the code taken from your HTL. If it is not typo in your actual HTL, then try doing the below

Capture the comparison value and then proceed further:

    

    data-sly-test.cmpVal = "${}"

     data-sly-test=${!cmpVal} or ${cmpVal}

Highlighted

elizabethp60981

28-02-2018

Hi,

The problem was that we was doing everything inside the same tag <sly>

and it was getting confused when processing

We divided the compare on two tags <div> and now are working.

Thank you