Expand my Community achievements bar.

SOLVED

<sly data-sly-test /> with multiple test statements in single tag not working

Avatar

Level 2

<sly data-sly-test.var1="${testCondition}"

        data-sly-test.var2="${testCondition}"

        data-sly-test.var3="${testCondition}"/>

<div class="test1"  value=${var1}></div>

<div class="test2" value= ${var2}></div>

<div class="test3"  value=${var3}></div>

any help on using single sly tag to use with  "data-sly-test" multiple statements.

1 Accepted Solution

Avatar

Correct answer by
Level 2

Hi Susheel,

Thanks for your reply you are right flow gets stop if its evaluated to false.I will have separate data-sly-test for each div sections.

Thanks,

Manjunath DJ

View solution in original post

4 Replies

Avatar

Community Advisor

Hi Manju,

I don't think it will work.

You can write the test condition for specific div.

<sly data-sly-test.var1="${testCondition}" >

<div class="test1"  value=${var1}></div></sly>

~ Prince

Avatar

Level 5

Hi Manju,

Here it seems like you are trying to declare 3 variables are trying to use it later in the code.

But this to work correctly all the three declarations should have true or some string values.

Wherever a variable is evaluated to false, the flow will stop and next variable will not be intialized.

Object var1 = null;

Object var12 = null;

Object var13 = null;

var1 = "somevariable1";

if (renderContext.toBoolean(var1)) {

var12 = "somevariable2";

    if (renderContext.toBoolean(var12)) {

var13 = "somevariable2";

        if (renderContext.toBoolean(var13)) {

        }

    }

}

Your code will be generated something like above. So for all the variables to be initialized, at least first two variables should be evaluated to true. It should have some string or Boolean(evaluating to true).

Avatar

Level 2

Hi Shivhare,

Thanks for the reply. I will have separate data-sly-test for each div sections.

Thanks,

Manjunath DJ

Avatar

Correct answer by
Level 2

Hi Susheel,

Thanks for your reply you are right flow gets stop if its evaluated to false.I will have separate data-sly-test for each div sections.

Thanks,

Manjunath DJ