This is an automated email from the ASF dual-hosted git repository.
kwin 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 57ce586 SLING-9958 document scripting encodings (#64)
57ce586 is described below
commit 57ce58645f0f943eff2bf46aab2d505c39937f26
Author: Konrad Windszus <[email protected]>
AuthorDate: Mon Jul 26 10:24:21 2021 +0200
SLING-9958 document scripting encodings (#64)
Co-authored-by: Radu Cotescu <[email protected]>
---
src/main/jbake/content/documentation/bundles/scripting.md | 6 ++++++
.../content/documentation/the-sling-engine/resources.md | 15 +++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/src/main/jbake/content/documentation/bundles/scripting.md
b/src/main/jbake/content/documentation/bundles/scripting.md
index aa36b07..6252697 100644
--- a/src/main/jbake/content/documentation/bundles/scripting.md
+++ b/src/main/jbake/content/documentation/bundles/scripting.md
@@ -67,6 +67,12 @@ Mapping `html` to Thymeleaf 3.0:
"html=Thymeleaf:3.0"
]
+## Script encoding
+
+All scripts backed by Sling resources get their character encoding from the
[character encoding set in the resource
metadata](../the-sling-engine/resources.html#resource-properties). For JCR
based resources this is retrieved from the underlying `jcr:encoding` JCR
property. If not set it will fall back to UTF-8.
+
+Every script evaluation in the context of a request sets the response's
character encoding to UTF-8 (if the request accepts content types starting with
`text/`)
+
## 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).
diff --git a/src/main/jbake/content/documentation/the-sling-engine/resources.md
b/src/main/jbake/content/documentation/the-sling-engine/resources.md
index d1a0304..ff5019e 100644
--- a/src/main/jbake/content/documentation/the-sling-engine/resources.md
+++ b/src/main/jbake/content/documentation/the-sling-engine/resources.md
@@ -155,6 +155,21 @@ The main binary property (i.e. the one being exposed by
`Resource.adaptTo(InputS
For node type `nt:file` the property is looked up in the child node
`jcr:content` for both cases. For all other node types it is looked up in the
underlying node of the current resource.
+#### Resource Metadata
+
+The resource metadata exposed in `Resource.getResourceMetadata` get their
values from JCR properties:
+
+Metadata Property | Backed by
+--- | --- | ---
+`sling.contentType` | JCR property `jcr:mimeType`
+`sling.characterEncoding` | JCR property `jcr:encoding`
+`sling.creationTime` | JCR property `jcr:created`
+`sling.modificationTime` | JCR property `jcr:lastModified`
+`sling.contentLength` | The content length of the JCR property `jcr:data` or
alternatively the primary item of the underlying Node (according to its node
type definition)
+
+For binary nodes all properties except `jcr:created` are retrieved from the
child node `jcr:content`.
+
+
### Bundle-based Resources
Resources may by provided by OSGi bundles. Providing bundles have a Bundle
manifest header `Sling-Bundle-Resources` containing a list of absolute paths
provided by the bundle. The path are separated by comma or whitespace (SP, TAB,
VTAB, CR, LF).