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

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

  • July 31, 2017
  • 4 replies
  • 4210 views

<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.
Best answer by Manjunath_DJ

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

Prince_Shivhare
Community Advisor
Community Advisor
July 31, 2017

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

susheel
Level 5
July 31, 2017

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

Manjunath_DJ
Level 2
August 1, 2017

Hi Shivhare,

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

Thanks,

Manjunath DJ

Manjunath_DJ
Manjunath_DJAuthorAccepted solution
Level 2
August 1, 2017

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