내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

How to implement Switch statement Using sightly

Avatar

Level 2

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

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Employee Advisor

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>

원본 게시물의 솔루션 보기

3 답변 개

Avatar

Level 9

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

 

Avatar

정확한 답변 작성자:
Employee Advisor

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>

Avatar

Level 10

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/