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 2020/09/18 21:21:23 UTC

[sling-site] branch master updated: add documentation for mapping script extensions to engines

This is an automated email from the ASF dual-hosted git repository.

olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-site.git


The following commit(s) were added to refs/heads/master by this push:
     new fee3b84  add documentation for mapping script extensions to engines
fee3b84 is described below

commit fee3b848bbee72dcda5443c65db05f562d19e48a
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Fri Sep 18 23:21:02 2020 +0200

    add documentation for mapping script extensions to engines
---
 .../content/documentation/bundles/scripting.md     | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/src/main/jbake/content/documentation/bundles/scripting.md b/src/main/jbake/content/documentation/bundles/scripting.md
index b1cd82d..aa36b07 100644
--- a/src/main/jbake/content/documentation/bundles/scripting.md
+++ b/src/main/jbake/content/documentation/bundles/scripting.md
@@ -34,6 +34,39 @@ Several more engines are available but experimental or no longer maintained:
 
 Code for really old modules might be found in the [svn attic](https://svn.apache.org/repos/asf/sling/attic).
 
+### Mapping script extensions to engines
+
+Since version `2.0.60` [Scripting Core](https://github.com/apache/sling-org-apache-sling-scripting-core) supports the mapping of extensions to engines in content ([SLING-4330](https://issues.apache.org/jira/browse/SLING-4330)).
+
+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 `html`).
+
+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:
+
+1. language name (required)
+2. language version (optional)
+3. engine name (not used yet)
+4. engine version (not used yet)
+
+The `sling:scripting` property supports multiple mappings for different extensions (e.g. `html` and `js`).
+
+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.
+
+#### Sample mappings
+
+Mapping `html` to HTL 1.4:
+
+    "sling:scripting": [
+      "html=The HTL Templating Language:1.4"
+    ]
+
+Mapping `html` to Thymeleaf 3.0:
+
+    "sling:scripting": [
+      "html=Thymeleaf:3.0"
+    ]
+
 ## Scripting variables
 
 See also [Scripting variables](https://cwiki.apache.org/confluence/display/SLING/Scripting+variables) and [Adding New Scripting Variables](https://cwiki.apache.org/confluence/display/SLING/Adding+New+Scripting+Variables).