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

kwin pushed a commit to branch feature/scripting-encoding
in repository https://gitbox.apache.org/repos/asf/sling-site.git

commit d29ae6e00a35ca03c41f2ec91426c6949a2715d7
Author: Konrad Windszus <[email protected]>
AuthorDate: Fri Jul 23 17:55:46 2021 +0200

    SLING-9958 document scripting encodings
---
 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..58a26f7 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 set the response's 
character encoding to UTF-8 (if the requests 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..fc423bc 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 
value 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).

Reply via email to