1
votes

I need to do some string operations in sightly, like checking if the string is starting with '/content' and if yes append '.html' at the end. Is this possible in sightly ?

2

2 Answers

2
votes

Sightly was designed specifically to avoid having such logic in sightly templates. What you need to do is, you need to create a Sling Model for your component that is going to perform the logic you want and expose the result from there.

On a side note, in your particular use case, you might want to take a closer look at AEM's link checker.

1
votes

You could however do something like this:

<a href="${properties.path ? properties.path : 'contact'}.html">${properties.link ? properties.link : 'Get in Touch'}</a>