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 compare strings in sightly?

Avatar

Avatar
Validate 1
Level 1
umangm67314486
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
umangm67314486
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
umangm67314486
Level 1

12-08-2016

Hi Everyone, 

I need help with comparing string data using sightly : data-sly-test Please help me if you know how to do that. This is what I tried but didn't worked.

 

     <sly  data-sly-test.var1="${abc.xyz.name}"></sly>
     <sly  data-sly-test.var2=" ${'abc.xyz.lmn' @i18n}"></sly>
     <sly  data-sly-test.var3=" ${'abc.xyz.jkl' @i18n}"></sly>


${var1}

${var2}

                            <div data-sly-test="${var1 == var2}">TEST</div>
                            <div data-sly-test="${var1 == var3}">NOT TEST</div>

 

 

I got Output as values of var1 & 2 but no output for data-sly-test.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,130 likes

Total Posts

6,157 posts

Correct Reply

1,144 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,130 likes

Total Posts

6,157 posts

Correct Reply

1,144 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile
kautuk_sahni
Community Manager

16-08-2016

Hi 

I Just tried the following:-

<div data-sly-test.var1="${currentPage.title}">
            Test 1
    </div>
    <div data-sly-test.var2="${currentPage.title}">
            Test 1.1
    </div>
    ${var1}
    ${var2}

    <div data-sly-test="${var1==var2}">
            Test 2
    </div>

Output is:- 

Test 1
Test 1.1
HTLMFPage HTLMFPage
Test 2
 

~kautuk

Answers (2)

Answers (2)

Avatar

Avatar
Validate 1
Level 2
ebin_Aby
Level 2

Likes

7 likes

Total Posts

25 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
ebin_Aby
Level 2

Likes

7 likes

Total Posts

25 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
ebin_Aby
Level 2

07-08-2019

kautuksahni​ : Is there any way i can check in htl if the page URL contain specific path.

Avatar

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,130 likes

Total Posts

6,157 posts

Correct Reply

1,144 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile

Avatar
Establish
Community Manager
kautuk_sahni
Community Manager

Likes

1,130 likes

Total Posts

6,157 posts

Correct Reply

1,144 solutions
Top badges earned
Establish
Coach
Originator
Contributor 2
Contributor
View profile
kautuk_sahni
Community Manager

16-08-2016

Also have a look at this post :- http://stackoverflow.com/questions/30388281/how-to-say-if-something-equals-to-a-string-in-sightly

//This talks about "How to say if something equals to a string in Sightly?"

 

PS:- HTML Template Langue formerly known as sightly. 

~kautuk