Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How to implement Switch statement Using sightly

Avatar

Avatar
Validate 1
Level 2
rama_krishna11
Level 2

Likes

4 likes

Total Posts

18 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 2
rama_krishna11
Level 2

Likes

4 likes

Total Posts

18 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 3
Boost 1
Affirm 1
View profile
rama_krishna11
Level 2

03-02-2016

For example, in jstl the switch statement like below

<c:choose><c:when test="${salary <= 0}"> Salary is very low to survive.</c:when><c:when test="${salary > 1000}"> Salary is very good.</c:when><c:otherwise>No comment sir...</c:otherwise></c:choose>

 

Need to convert the above switch statement to sightly. Please help me in this

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 10
MVP
kunal23
MVP

Likes

166 likes

Total Posts

565 posts

Correct Reply

172 solutions
Top badges earned
Validate 10
Validate 1
Ignite 3
Ignite 1
Give Back 50
View profile

Avatar
Validate 10
MVP
kunal23
MVP

Likes

166 likes

Total Posts

565 posts

Correct Reply

172 solutions
Top badges earned
Validate 10
Validate 1
Ignite 3
Ignite 1
Give Back 50
View profile
kunal23
MVP

03-02-2016

Try the following code- 

<div data-sly-test="${salary < 0}" data-sly-unwrap> Salary is very low to survive </div> <div data-sly-test="${salary >  1000}" data-sly-unwrap> Salary is very good. </div> <div data-sly-test="${salary < 1000} && ${salary > 0}" data-sly-unwrap> No comment sir... </div>

Answers (2)

Answers (2)

Avatar

Avatar
Validate 1
Level 10
edubey
Level 10

Likes

276 likes

Total Posts

1,502 posts

Correct Reply

392 solutions
Top badges earned
Validate 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Validate 1
Level 10
edubey
Level 10

Likes

276 likes

Total Posts

1,502 posts

Correct Reply

392 solutions
Top badges earned
Validate 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
edubey
Level 10

03-02-2016

Hi Rama,

Approach I could suggest is, you can write this in sightly JS ( executes in server side) file as it supports switch. Take a look at this article on how you can us JS code sightly http://adobeaemclub.com/javascript-use-api-with-a-simple-component-in-sightly/ 

Avatar

Avatar
Validate 1
Level 7
Jitendra_S_Toma
Level 7

Likes

74 likes

Total Posts

615 posts

Correct Reply

84 solutions
Top badges earned
Validate 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Validate 1
Level 7
Jitendra_S_Toma
Level 7

Likes

74 likes

Total Posts

615 posts

Correct Reply

84 solutions
Top badges earned
Validate 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
Jitendra_S_Toma
Level 7

03-02-2016

All of these conditional changes, you should be doing in a simple POJO. It is better, If You should avoid such logic at the template level.

Jitendra

Rama Krishna wrote...

For example, in jstl the switch statement like below

 

Need to convert the above switch statement to sightly. Please help me in this