<sly data-sly-test /> with multiple test statements in single tag not working | Community
Skip to main content
Manjunath_DJ
Level 2
Jul 31, 2017 2:56 PM UTC
Solved

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

<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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Manjunath_DJ
Manjunath_DJAccepted solution
Level 2
Aug 1, 2017 5:39 AM UTC

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

4 replies

Manjunath_DJ
Manjunath_DJAuthorAccepted solution
Level 2
Aug 1, 2017 5:39 AM UTC

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

Translate
Manjunath_DJ
Level 2
Aug 1, 2017 5:32 AM UTC

Hi Shivhare,

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

Thanks,

Manjunath DJ

Translate
susheel
Level 5
Jul 31, 2017 5:29 PM UTC

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).

Translate
Prince_Shivhare
New Participant
Jul 31, 2017 4:09 PM UTC

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

Translate