Code4life
Code4life

Reputation: 67

Append class with if statement

I just created a variable for a specific site of mine but I want to append a class entitled "partner-text" if I'm actually on that site. If I'm on a different site then don't append it. How can I do that?

use(function() {
var inPartnerPath = currentPage.getPath().indexOf("partners_Skate_Daily");
// to check if the site is under partners_Skate_Daily folder if yes then it should return true

var isPartner = (inPartnerPath != -1) ? 'true' : 'false';

return {
    isPartner: isPartner
};

});

Upvotes: 0

Views: 69

Answers (1)

gen_Eric
gen_Eric

Reputation: 227280

'true' and 'false' are strings. You want to use the boolean values true/false.

You don't even need the ?: here, != already returns you a boolean.

var isPartner = inPartnerPath != -1;

Upvotes: 2

Related Questions