Sling Scripting is build around Java Scripting API (JSR 223). It allows the easy development and usage of different scripting (aka templating) engines.
The script engines are managed in
SlingScriptEngineManager (Scripting Core).
|Engine||Language Name||Language Version||Names||Extensions||Mime Types||GitHub Repo(s)||Documentation|
|FreeMarker|| || || |
|Groovy (GString)|| || || |
|HTL|| || || || ||sling-org-apache-sling-scripting-sightly||Scripting HTL|
|Java|| || || || ||sling-org-apache-sling-scripting-java|
|JSP|| || || || ||sling-org-apache-sling-scripting-jsp||Scripting JSP|
|Thymeleaf|| || || |
Several more engines are available but experimental or no longer maintained:
Code for really old modules might be found in the svn attic.
This is required when registering more than one script engine for a single script extension (e.g. using HTL for vendor-related scripts in
/libs and Thymeleaf for project-related scripts in
/apps, both using extension
It works by adding a
sling:scripting property to the script resource or a resource in the hierarchy above the script (e.g. project or parent folder).
The mapping consists of a key which is the script extension and a value which itself could consist of four values separated by colon to identify the script engine:
sling:scripting property supports multiple mappings for different extensions (e.g.
In case there is more than one script engine for a script extension registered and no mapping is found the script engine with higher service ranking gets used for rendering.
html to HTL 1.4:
"sling:scripting": [ "html=The HTL Templating Language:1.4" ]
html to Thymeleaf 3.0:
"sling:scripting": [ "html=Thymeleaf:3.0" ]