Apache
Home » Documentation » Bundles » Sling Scripting

Sling Scripting Thymeleaf

Sling Scripting Thymeleaf is the scripting engine for Thymeleaf (3.0) templates.

Features

Installation

For running Sling Scripting Thymeleaf with Sling's Launchpad some dependencies need to be resolved. This can be achieved by installing the following bundles:

mvn:org.attoparser/attoparser/2.0.2.RELEASE
mvn:org.unbescape/unbescape/1.1.4.RELEASE
mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.ognl/3.2_1
mvn:org.javassist/javassist/3.20.0-GA

There is a feature for Karaf:

karaf@root()> feature:install sling-scripting-thymeleaf

Note: Sling Scripting Thymeleaf requires an implementation of OSGi Declarative Services 1.3 (e.g. Apache Felix Service Component Runtime 2.0.0 or greater)

Configuration

Apache Sling Scripting Thymeleaf “ScriptEngineFactory”

By default Sling Scripting Thymeleaf's ScriptEngineFactory is configured for templates with extension html and mime type text/html and uses all of Thymeleaf's standard extensions either also or exclusively.

Apache Sling Scripting Thymeleaf “ScriptEngineFactory”

Apache Sling Scripting Thymeleaf “Sling Resource TemplateResolver”

The Sling Resource TemplateResolver is configured to resolve templates with use decoupled logic enabled.

Apache Sling Scripting Thymeleaf “Sling Resource TemplateResolver”

Apache Sling Scripting Thymeleaf “Pattern TemplateModeProvider”

The Pattern TemplateModeProvider is configured to match template paths against default extensions for providing template modes (of course except no-op mode RAW).

Apache Sling Scripting Thymeleaf “Pattern TemplateModeProvider

Apache Sling Scripting Thymeleaf “ResourceBundle MessageResolver”

The ResourceBundle MessageResolver is configured to use the message's key as absent message representation.

Apache Sling Scripting Thymeleaf “ResourceBundle MessageResolver”

Sling Dialect

Sling Scripting Thymeleaf comes with its own dialect using the sling prefix/namespace currently supporting the include feature known from Sling Scripting JSP Taglib.

include

<header data-sling-include="${resource}" data-sling-resourceType="'example/page/header'" data-sling-unwrap="true"/>

include - The resource object (Resource) or the path (String) of the resource object to include in the current request processing. If this path is relative it is appended to the path of the current resource whose script is including the given resource.

supported options (* = RequestDispatcher option)

Class Diagram

Class Diagram

Sample

The Sling Fling Sample is a sample using Sling Scripting Thymeleaf with Sling Models and Sling Query.

Sling Fling Sample

Rev. 1784878 by olli on Wed, 1 Mar 2017 08:42:58 +0000
Apache Sling, Sling, Apache, the Apache feather logo, and the Apache Sling project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.