You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ol...@apache.org on 2016/07/02 18:35:37 UTC
svn commit: r1751087 -
/sling/site/trunk/content/documentation/bundles/scripting/
Author: olli
Date: Sat Jul 2 18:35:37 2016
New Revision: 1751087
URL: http://svn.apache.org/viewvc?rev=1751087&view=rev
Log:
update documentation of Sling Scripting Thymeleaf
Added:
sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-Class-Diagram.png (with props)
sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-Pattern-TemplateModeProvider.png (with props)
sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-ResourceBundle-MessageResolver.png (with props)
sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-ScriptEngineFactory.png (with props)
sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-Sling-Resource-TemplateResolver.png (with props)
Removed:
sling/site/trunk/content/documentation/bundles/scripting/class-diagram.svg
sling/site/trunk/content/documentation/bundles/scripting/scripting-thymeleaf-html5-template-mode-handler.png
sling/site/trunk/content/documentation/bundles/scripting/scripting-thymeleaf-non-caching-template-resolver.png
sling/site/trunk/content/documentation/bundles/scripting/scripting-thymeleaf-script-engine-factory.png
Modified:
sling/site/trunk/content/documentation/bundles/scripting/scripting-thymeleaf.mdtext
Added: sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-Class-Diagram.png
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-Class-Diagram.png?rev=1751087&view=auto
==============================================================================
Binary file - no diff available.
Propchange: sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-Class-Diagram.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-Pattern-TemplateModeProvider.png
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-Pattern-TemplateModeProvider.png?rev=1751087&view=auto
==============================================================================
Binary file - no diff available.
Propchange: sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-Pattern-TemplateModeProvider.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-ResourceBundle-MessageResolver.png
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-ResourceBundle-MessageResolver.png?rev=1751087&view=auto
==============================================================================
Binary file - no diff available.
Propchange: sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-ResourceBundle-MessageResolver.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-ScriptEngineFactory.png
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-ScriptEngineFactory.png?rev=1751087&view=auto
==============================================================================
Binary file - no diff available.
Propchange: sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-ScriptEngineFactory.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-Sling-Resource-TemplateResolver.png
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-Sling-Resource-TemplateResolver.png?rev=1751087&view=auto
==============================================================================
Binary file - no diff available.
Propchange: sling/site/trunk/content/documentation/bundles/scripting/Scripting-Thymeleaf-Sling-Resource-TemplateResolver.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: sling/site/trunk/content/documentation/bundles/scripting/scripting-thymeleaf.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/bundles/scripting/scripting-thymeleaf.mdtext?rev=1751087&r1=1751086&r2=1751087&view=diff
==============================================================================
--- sling/site/trunk/content/documentation/bundles/scripting/scripting-thymeleaf.mdtext (original)
+++ sling/site/trunk/content/documentation/bundles/scripting/scripting-thymeleaf.mdtext Sat Jul 2 18:35:37 2016
@@ -1,49 +1,56 @@
Title: Sling Scripting Thymeleaf
-Sling Scripting Thymeleaf is the scripting engine for [_Thymeleaf_](http://www.thymeleaf.org) templates.
+Sling Scripting Thymeleaf is the scripting engine for [_Thymeleaf_](http://www.thymeleaf.org) (3.0) templates.
[TOC]
# Features
-* out of the box support for _legacy_ HTML5 through embedded _NekoHTML_
-* runtime configurable `TemplateModeHandler`s for _XML_, _VALIDXML_, _XHTML_, _VALIDXHTML_, _HTML5_ and _LEGACYHTML5_
-* `ResourceResolver` backed by Sling's `ResourceResolver`
-* `MessageResolver` backed by `ResourceBundleProvider` from `org.apache.sling.i18n`
+* Supporting all of Thymeleaf's extension points: [_TemplateResolver_](http://www.thymeleaf.org/apidocs/thymeleaf/3.0.0.RELEASE/org/thymeleaf/templateresolver/ITemplateResolver.html)s, [_MessageResolver_](http://www.thymeleaf.org/apidocs/thymeleaf/3.0.0.RELEASE/org/thymeleaf/messageresolver/IMessageResolver.html)s, [_Dialect_](http://www.thymeleaf.org/apidocs/thymeleaf/3.0.0.RELEASE/org/thymeleaf/dialect/IDialect.html)s, [_LinkBuilder_](http://www.thymeleaf.org/apidocs/thymeleaf/3.0.0.RELEASE/org/thymeleaf/linkbuilder/ILinkBuilder.html)s, [_DecoupledTemplateLogicResolver_](http://www.thymeleaf.org/apidocs/thymeleaf/3.0.0.RELEASE/org/thymeleaf/templateparser/markup/decoupled/IDecoupledTemplateLogicResolver.html), [_CacheManager_](http://www.thymeleaf.org/apidocs/thymeleaf/3.0.0.RELEASE/org/thymeleaf/cache/ICacheManager.html) and [_EngineContextFactory_](http://www.thymeleaf.org/apidocs/thymeleaf/3.0.0.RELEASE/org/thymeleaf/context/IEngineContext.html)
+* `SlingResourceTemplateResolver` customizable through `TemplateModeProvider`
+* `ResourceBundleMessageResolver` backed by `ResourceBundleProvider` from [Sling i18n](https://sling.apache.org/documentation/bundles/internationalization-support-i18n.html) customizable through optional `AbsentMessageRepresentationProvider`
+* `PatternTemplateModeProvider` supporting [`Pattern`](https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html) configurations for all [template modes](http://www.thymeleaf.org/apidocs/thymeleaf/3.0.0.RELEASE/org/thymeleaf/templatemode/TemplateMode.html) (`HTML`, `XML`, `TEXT`, `JAVASCRIPT`, `CSS` and `RAW`)
* `SlingDialect`
-
-# Class Diagram
-
-[](class-diagram.svg)
+* Thymeleaf's [`TemplateEngine`](http://www.thymeleaf.org/apidocs/thymeleaf/3.0.0.RELEASE/org/thymeleaf/ITemplateEngine.html) registered as OSGi Service ([`ITemplateEngine`](http://www.thymeleaf.org/apidocs/thymeleaf/3.0.0.RELEASE/org/thymeleaf/ITemplateEngine.html)) for direct use
# 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:
+For running Sling Scripting Thymeleaf with Sling's Launchpad some dependencies need to be resolved. This can be achieved by installing the following bundle:
- mvn:org.apache.sling/org.apache.sling.i18n/2.2.10
- mvn:org.javassist/javassist/3.18.2-GA
- mvn:commons-io/commons-io/2.4
- mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xerces/2.11.0_1
- mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xmlresolver/1.2_5
+ mvn:org.javassist/javassist/3.20.0-GA
There is a feature for Karaf:
karaf@root()> feature:repo-add mvn:org.apache.sling/org.apache.sling.launchpad.karaf-features/0.1.1-SNAPSHOT/xml/features
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](http://felix.apache.org/documentation/subprojects/apache-felix-service-component-runtime.html) 2.0.0 or greater)
+
# Configuration
-By default Sling Scripting Thymeleaf's _Script Engine Factory_ is configured for templates with extension `html` and mime type `text/html`.
+## 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 “Sling Resource TemplateResolver”
-
+The _Sling Resource TemplateResolver_ is configured to resolve templates with _use decoupled logic_ enabled.
-The _Non-Caching Template Resolver_ (the only available template resolver for now) is configured to read templates with encoding `UTF-8`.
+
-
+## Apache Sling Scripting Thymeleaf “Pattern TemplateModeProvider”
-At least one template mode handler (e.g. _HTML5 Template Mode Handler_) needs to be configured with a pattern to process templates by Sling Scripting Thymeleaf:
+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 “ResourceBundle MessageResolver”
+
+The _ResourceBundle MessageResolver_ is configured to use the message's key as absent message representation.
+
+
# Sling Dialect
@@ -51,9 +58,9 @@ Sling Scripting Thymeleaf comes with its
## include
-`<header data-sling-include="${resource}" resourceType="'example/page/header'" unwrap="true"/>`
+`<header data-sling-include="${resource}" data-sling-resourceType="'example/page/header'" data-sling-unwrap="true"/>`
-`include` - The resource object ([`Resource`](http://sling.apache.org/apidocs/sling7/org/apache/sling/api/resource/Resource.html)) or the path (`String`) to 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.
+`include` - The resource object ([`Resource`](http://sling.apache.org/apidocs/sling7/org/apache/sling/api/resource/Resource.html)) 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](http://sling.apache.org/apidocs/sling7/org/apache/sling/api/request/RequestDispatcherOptions.html))
@@ -63,6 +70,10 @@ Sling Scripting Thymeleaf comes with its
* `resourceType` (`String`) *: The resource type of a resource to include. If the resource to be included is specified with the path attribute, which cannot be resolved to a resource, the tag may create a synthetic resource object out of the path and this resource type. If the resource type is set the path must be the exact path to a resource object. That is, adding parameters, selectors and extensions to the path is not supported if the resource type is set.
* `unwrap` (`Boolean`): removes the host element
+# Class Diagram
+
+[](Scripting-Thymeleaf-Class-Diagram.png)
+
# Sample
The [Sling Fling Sample](http://svn.apache.org/repos/asf/sling/trunk/samples/fling/) is a sample using Sling Scripting Thymeleaf with [Sling Models]({{ refs.models.path }}) and [Sling Query]({{ refs.sling-query.path }}).