0
votes

I am using AEM6.0 and in one of sightly scripts, i am having two variables

${currentPage.path} -? /content/geometrixx/en/tools

${pageHref} -> /content/geometrixx/en/tools.html

Now i need to compare these two but as ${currentPage.path} does not have .html, it will fail. Is there any way i can append .html to it to compare it successfully.

1

1 Answers

2
votes

No. There is no direct way to do it. The following excerpt from the Sightly docs tells you why

Separation of Concerns: The expressiveness of the Sightly template language is purposely limited, in order to make sure that a real programming language is used to express the corresponding presentation logic. This optional logic is invoked from Sightly expressions with the Use-API pattern, making it easy to understand what is called for a given view, and to potentially have different logic for different views of the same resource.

I would suggest either using a Java / JavaScript Use API to achieve the same.

However if it is inevitable that you need to do this in Sightly itself, then you can use the following dirty hack, though I wouldn't recommend it.

<sly data-sly-test.pagePath = "${currentPage.path}.html"></sly>
<sly data-sly-test = "${pageHref == pagePath}">
    <!--/** Your HTML here */-->
</sly> 

A similar kind of question has been answered here.