Hi
I am getting the below error in my pages from my page.html. Does anyone already faced this issue before ?
HTML
<!doctype html>
<html lang="en" class="js csscolumns svg">
<head>
<sly data-sly-include="partials/head.html" data-sly-unwrap/>
<sly data-sly-include="partials/headlibs.html" data-sly-unwrap/>
</head>
<body class="page ${currentPage.template.name}">
<sly data-sly-include="partials/main.html" data-sly-unwrap/>
<sly data-sly-include="partials/footlibs.html" data-sly-unwrap/>
</body>
</html>
org.apache.sling.scripting.sightly.SightlyException: coerceToString is an internal method at io.sightly.java.impl.slingAdapter.ObjectModelAdapter.coerceToString(ObjectModelAdapter.java:43) at com.adobe.cq.sightly.internal.extensions.IncludeExtension$1.call(IncludeExtension.java:63) at io.sightly.java.impl.graniteAdapter.RuntimeExtensionAdapter.call(RuntimeExtensionAdapter.java:37) at org.apache.sling.scripting.sightly.impl.engine.runtime.RenderContextImpl.call(RenderContextImpl.java:89)
TIA
Veena
Solved! Go to Solution.
${currentPage.template} only works with the right permissions, nothing to do with the dispatcher.
Basically: never use getTemplate() :-)
Create a new project using Maven 10 project.
https://helpx.adobe.com/experience-manager/using/first-arch10.html
Take a look at some of the default HTML pages -- for example:
<html lang="en">
<head>
<sly data-sly-include="partials/head.html" data-sly-unwrap/>
<sly data-sly-include="partials/headlibs.html" data-sly-unwrap/>
</head>
<body class="page ${currentPage.template.name}">
<sly data-sly-include="partials/main.html" data-sly-unwrap/>
<sly data-sly-include="partials/footlibs.html" data-sly-unwrap/>
</body>
</html>
You should not be seeing that error. Compare the code on that project with yours.
Views
Replies
Total Likes
Thanks for the quick response scott. I installed the package in a fresh instance and all started working fine. I am not sure what has happened to the instance before
Views
Replies
Total Likes
Could have been an outdated file or something. Glad its working.
Views
Replies
Total Likes
Also you shouldn't use $[currentPage.template} - it'll be blocked on the dispatcher due to permissions.
Views
Replies
Total Likes
${currentPage.template} only works with the right permissions, nothing to do with the dispatcher.
Basically: never use getTemplate() :-)