Skip to content

Instantly share code, notes, and snippets.

@EdwardRayl
Last active October 18, 2022 03:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save EdwardRayl/2583c714e715700dd06311d10e754da8 to your computer and use it in GitHub Desktop.
Save EdwardRayl/2583c714e715700dd06311d10e754da8 to your computer and use it in GitHub Desktop.
Apache Sling HTL example file, dumping most of the values available in the global objects
<!DOCTYPE html>
<html>
<head>
<title>HTL Values and Properties</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<style>
body{margin:10}table{border-collapse:collapse;border:2px solid black;padding:4px}
td,th,tr{font:700 13px/140% verdana,helvetica,arial,sans-serif}
td,th{padding-left:10px;padding-right:10px}th{color:#5f53bd;font-size:120%;font-weight:800}
td.name{text-align:right}td.value,th.name,th.value{text-align:left}
</style>
</head>
<body>
<!-- Written by Edward Rayl -->
<h1>Renderer: ${properties.sling:resourceType}/htl.html</h1>
<sly data-sly-test="${currentPage}">
<h2>Breadcrumbs:
<sly data-sly-test="${currentPage.parent.parent.parent.parent}">
${currentPage.parent.parent.parent.parent.title} >
</sly>
<sly data-sly-test="${currentPage.parent.parent.parent}">
${currentPage.parent.parent.parent.title} >
</sly>
<sly data-sly-test="${currentPage.parent.parent}">
${currentPage.parent.parent.title} >
</sly>
<sly data-sly-test="${currentPage.parent}">
${currentPage.parent.title} >
</sly>
${currentPage.title}
<br/><br/>
<sly data-sly-test="${currentPage.listChildren}">
Children:
<sly data-sly-list="${currentPage.listChildren}">
${item.title} -
</sly>
</sly>
</h2>
</sly>
<h2>Request Properties</h2>
<table border="1">
<tr>
<th class="name">Name</th>
<th class="value">Value</th>
</tr>
<tr>
<td class="name">Title</td>
<td>${properties.jcr:title || properties.pageTitle || resource.name}</td>
</tr>
<tr>
<td class="name">Description</td>
<td>${properties.jcr:description}</td>
</tr>
<tr>
<td class="name">Current Node</td>
<td>${properties.jcr:currentNode}</td>
</tr>
<tr>
<td class="name">Resource Type</td>
<td>${properties.sling:resourceType}</td>
</tr>
<tr>
<td class="name">Primary Type</td>
<td>${properties.jcr:primaryType}</td>
</tr>
</table>
<h2>Sling Decomposed URI</h2>
<table border="1">
<tr>
<th class="name">Name</th>
<th class="value">Value</th>
</tr>
<tr>
<td class="name">Protocol</td>
<td>${request.scheme}://</td>
</tr>
<tr>
<td class="name">Host &amp; Port</td>
<td>${request.serverName}:${request.localPort}</td>
</tr>
<tr>
<td class="name">Content Path</td>
<td>${request.requestPathInfo.resourcePath}</td>
</tr>
<tr>
<td class="name">Selectors</td>
<td>${request.requestPathInfo.selectorString}</td>
</tr>
<tr>
<td class="name">Extension</td>
<td>${request.requestPathInfo.extension}</td>
</tr>
<tr>
<td class="name">Suffix</td>
<td>${request.requestPathInfo.suffix}</td>
</tr>
<tr data-sly-test=${request.requestPathInfo.suffixResource.name}>
<td class="name">Suffix Resource</td>
<td>${request.requestPathInfo.suffixResource.name}</td>
</tr>
<tr data-sly-test=${request.queryString}>
<td class="name">Parameters</td>
<td>${request.queryString}</td>
</tr>
</table>
<sly data-sly-test="${currentPage}">
<h2>Page Values</h2>
<table border="1">
<tr>
<th class="name">Name</th>
<th class="value">Value</th>
</tr>
<tr>
<td class="name">Content Resource</td>
<td>${currentPage.contentResource.name}</td>
</tr>
<tr>
<td class="name">Deleted</td>
<td>${currentPage.deleted.time.toString}</td>
</tr>
<tr>
<td class="name">Deleted By</td>
<td>${currentPage.deletedBy}</td>
</tr>
<tr>
<td class="name">Depth</td>
<td>${currentPage.depth}</td>
</tr>
<tr>
<td class="name">Last Modified</td>
<td>${currentPage.lastModified.time.toString}</td>
</tr>
<tr>
<td class="name">Last Modified By</td>
<td>${currentPage.lastModifiedBy}</td>
</tr>
<tr>
<td class="name">Lock Owner</td>
<td>${currentPage.lockOwner}</td>
</tr>
<tr>
<td class="name">Name</td>
<td>${currentPage.name}</td>
</tr>
<tr>
<td class="name">Navigation Title</td>
<td>${currentPage.navigationTitle}</td>
</tr>
<tr>
<td class="name">Off Time</td>
<td>${currentPage.offTime.time.toString}</td>
</tr>
<tr>
<td class="name">Page Title</td>
<td>${currentPage.pageTitle}</td>
</tr>
<tr>
<td class="name">Parent Name</td>
<td>${currentPage.parent.name}</td>
</tr>
<tr>
<td class="name">Path</td>
<td>${currentPage.path}</td>
</tr>
<tr>
<td class="name">Template Title</td>
<td>${currentPage.template.title}</td>
</tr>
<tr>
<td class="name">Title</td>
<td>${currentPage.title}</td>
</tr>
<tr>
<td class="name">Vanity URL</td>
<td>${currentPage.vanityURL}</td>
</tr>
<tr>
<td class="name">Has Content?</td>
<td>${currentPage.content ? 'true' : 'false'}</td>
</tr>
<tr>
<td class="name">Locked?</td>
<td>${currentPage.locked ? 'true' : 'false'}</td>
</tr>
<tr>
<td class="name">Valid?</td>
<td>${currentPage.valid ? 'true' : 'false'}</td>
</tr>
</table>
<h2>Page Properties</h2>
<table border="1">
<thead>
<tr>
<th class="name">Name</th>
<th class="value">Value</th>
</tr>
</thead>
<tbody data-sly-list="${pageProperties}">
<tr>
<td class="name">${item}</td>
<td>${properties[item]}</td>
</tr>
</tbody>
</table>
<h2>Inherited Page Properties</h2>
<table border="1">
<thead>
<tr>
<th class="name">Name</th>
<th class="value">Value</th>
</tr>
</thead>
<tbody data-sly-list="${inheritedPageProperties}">
<tr>
<td class="name">${item}</td>
<td>${properties[item]}</td>
</tr>
</tbody>
</table>
</sly>
<sly data-sly-test="${currentNode}">
<h2>Node Values</h2>
<table border="1">
<tr>
<th class="name">Name</th>
<th class="value">Value</th>
</tr>
<tr>
<td class="name">Allowed Lifecycle Transistions</td>
<td>${currentNode.allowedLifecycleTransistions.toString}</td>
</tr>
<tr>
<td class="name">Corresponding Node Path</td>
<td>${currentNode.correspongingNodePath}</td>
</tr>
<tr>
<td class="name">Depth</td>
<td>${currentNode.depth}</td>
</tr>
<tr>
<td class="name">Identifier</td>
<td>${currentNode.identifier}</td>
</tr>
<tr>
<td class="name">Index</td>
<td>${currentNode.lastModified.time.toString}</td>
</tr>
<tr>
<td class="name">Primary Item</td>
<td>${currentNode.primaryItem.name}</td>
</tr>
<tr>
<td class="name">Name</td>
<td>${currentNode.name}</td>
</tr>
<tr>
<td class="name">UUID</td>
<td>${currentNode.UUID}</td>
</tr>
<tr>
<td class="name">Path</td>
<td>${currentNode.path}</td>
</tr>
<tr>
<td class="name">Template Title</td>
<td>${currentNode.template.title}</td>
</tr>
<tr>
<td class="name">Child Nodes?</td>
<td>${currentNode.nodes ? 'true' : 'false'}</td>
</tr>
<tr>
<td class="name">Properties?</td>
<td>${currentNode.properties ? 'true' : 'false'}</td>
</tr>
<tr>
<td class="name">Checked Out?</td>
<td>${currentNode.checkedOut ? 'true' : 'false'}</td>
</tr>
<tr>
<td class="name">Locked?</td>
<td>${currentNode.locked ? 'true' : 'false'}</td>
</tr>
<tr>
<td class="name">Primary or Mixin?</td>
<td>${currentNode.noteType ? 'true' : 'false'}</td>
</tr>
</table>
</sly>
<sly data-sly-test="${component}">
<h2>Component Values</h2>
<table border="1">
<thead>
<tr>
<th class="name">Name</th>
<th class="value">Value</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name">Cell Name</td>
<td>${component.cellName}</td>
</tr>
<tr>
<td class="name">SuperComponent Cell Name</td>
<td>${component.superComponent.cellName}</td>
</tr>
<tr>
<td class="name">Design Dialog Path</td>
<td>${component.designDialogPath}</td>
</tr>
<tr>
<td class="name">Dialog Path</td>
<td>${component.dialogPath}</td>
</tr>
<tr>
<td class="name">Icon Path</td>
<td>${component.iconPath}</td>
</tr>
<tr>
<td class="name">Resource Type</td>
<td>${component.resourceType}</td>
</tr>
<tr>
<td class="name">Template Path</td>
<td>${component.templatePath}</td>
</tr>
<tr>
<td class="name">Thumbnail Path</td>
<td>${component.thumbnailPath}</td>
</tr>
<tr>
<td class="name">Accessable?</td>
<td>${component.accessable ? 'true' : 'false'}</td>
</tr>
<tr>
<td class="name">Analyzable?</td>
<td>${component.analyzable ? 'true' : 'false'}</td>
</tr>
<tr>
<td class="name">Container?</td>
<td>${component.container ? 'true' : 'false'}</td>
</tr>
<tr>
<td class="name">Designable?</td>
<td>${component.designable ? 'true' : 'false'}</td>
</tr>
<tr>
<td class="name">Editable?</td>
<td>${component.editable ? 'true' : 'false'}</td>
</tr>
</tbody>
</table>
<h2>Component Properties</h2>
<table border="1">
<thead>
<tr>
<th class="name">Name</th>
<th class="value">Value</th>
</tr>
</thead>
<tbody data-sly-list="${component.properties}">
<tr>
<td class="name">${item}</td>
<td>${properties[item]}</td>
</tr>
</tbody>
</table>
</sly>
<sly data-sly-test="${componentContext}">
<h2>Component Context Values</h2>
<table border="1">
<tr>
<th class="name">Name</th>
<th class="value">Value</th>
</tr>
<tr>
<td class="name">CSS Class Names</td>
<td>${componentContext.cssClassNames.toString}</td>
</tr>
<tr>
<td class="name">Decoration Tag Name</td>
<td>${componentContext.decorationTagName}</td>
</tr>
<tr>
<td class="name">Default Decoration Tag Name</td>
<td>${componentContext.defaultDecorationTagName}</td>
</tr>
<tr>
<td class="name">Decoration?</td>
<td>${componentContext.decoration ? 'true' : 'false'}</td>
</tr>
<tr>
<td class="name">Root?</td>
<td>${componentContext.root ? 'true' : 'false'}</td>
</tr>
</table>
</sly>
<sly data-sly-test="${resource}">
<h2>Resource Properties</h2>
<table border="1">
<tr>
<th class="name">Name</th>
<th class="value">Value</th>
</tr>
<tr>
<td class="name">Parent</td>
<td>${resource.parent.name}</td>
</tr>
<tr>
<td class="name">Path</td>
<td>${resource.path}</td>
</tr>
<tr>
<td class="name">Resource Type</td>
<td>${resource.resourceType}</td>
</tr>
<tr>
<td class="name">Resource SuperType</td>
<td>${resource.resourceSuperType}</td>
</tr>
<tr>
<td class="name">Has Children?</td>
<td>${resource.children ? 'true' : 'false'}</td>
</tr>
</table>
<h2>Resource Metadata</h2>
<table border="1">
<thead>
<tr>
<th class="name">Name</th>
<th class="value">Value</th>
</tr>
</thead>
<tbody data-sly-list="${resource.resourceMetadata}">
<tr>
<td class="name">${item}</td>
<td>${resource.resourceMetadata[item][0].toString}</td>
</tr>
</tbody>
</table>
</sly>
<sly data-sly-test="${currentDesign}">
<h2>Design</h2>
<table border="1">
<tr>
<th class="name">Name</th>
<th class="value">Value</th>
</tr>
<tr>
<td class="name">CSS Path</td>
<td>${currentDesign.cssPath}</td>
</tr>
<tr>
<td class="name">ID</td>
<td>${currentDesign.id}</td>
</tr>
<tr>
<td class="name">Path</td>
<td>${currentDesign.path}</td>
</tr>
<tr>
<td class="name">Static CSS Path</td>
<td>${currentDesign.staticCssPath}</td>
</tr>
<tr>
<td class="name">Content?</td>
<td>${currentDesign.content ? 'true' : 'false'}</td>
</tr>
</table>
<!-- Too much information: ${currentDesign.JSON}<br/> -->
</sly>
<!--
* Request Scope
-->
<sly data-sly-test="${request.requestParameterMap}">
<h2>Request Parameters</h2>
<table border="1">
<thead>
<tr>
<th class="name">Name</th>
<th class="value">Value</th>
</tr>
</thead>
<tbody data-sly-list="${request.requestParameterMap}">
<tr>
<td>${item}</td>
<td>${request.requestParameterMap[item][0].toString}</td>
</tr>
</tbody>
</table>
</sly>
<h2>Request Information</h2>
<table border="1">
<tr>
<th class="name">Name</th>
<th class="value">Value</th>
</tr>
<tr>
<td class="name">Character Encoding</td>
<td>${request.characterEncoding}</td>
</tr>
<tr>
<td class="name">Content Length</td>
<td>${request.contentLength}</td>
</tr>
<tr>
<td class="name">Content Type</td>
<td>${request.contentType}</td>
</tr>
<tr>
<td class="name">Context Path</td>
<td>${request.contextPath}</td>
</tr>
<tr>
<td class="name">Locale</td>
<td>${request.locale}</td>
</tr>
<tr>
<td class="name">Local Address</td>
<td>${request.localAddr}</td>
</tr>
<tr>
<td class="name">Local Name</td>
<td>${request.localName}</td>
</tr>
<tr>
<td class="name">Local Port</td>
<td>${request.localPort}</td>
</tr>
<tr>
<td class="name">Method</td>
<td>${request.method}</td>
</tr>
<tr>
<td class="name">Path Info</td>
<td>${request.pathInfo || " "}</td>
</tr>
<tr>
<td class="name">Path Translated</td>
<td>${request.pathTranslated || " "}</td>
</tr>
<tr>
<td class="name">Protocol</td>
<td>${request.protocol}</td>
</tr>
<tr>
<td class="name">Query String</td>
<td>${request.queryString}</td>
</tr>
<tr>
<td class="name">Remote Address</td>
<td>${request.remoteAddr}</td>
</tr>
<tr>
<td class="name">Remote Host</td>
<td>${request.remoteHost}</td>
</tr>
<tr>
<td class="name">Remote Port</td>
<td>${request.remotePort}</td>
</tr>
<tr>
<td class="name">Request URI</td>
<td>${request.requestURI}</td>
</tr>
<tr>
<td class="name">Request URL</td>
<td>${request.requestURL}</td>
</tr>
<tr>
<td class="name">Requested Session Id</td>
<td>${request.requestedSessionId}</td>
</tr>
<tr>
<td class="name">Scheme</td>
<td>${request.scheme}</td>
</tr>
<tr>
<td class="name">Secure</td>
<td>${request.secure}</td>
</tr>
<tr>
<td class="name">Server Name</td>
<td>${request.serverName}</td>
</tr>
<tr>
<td class="name">Server Port</td>
<td>${request.serverPort}</td>
</tr>
<tr>
<td class="name">Servlet Path</td>
<td>${request.servletPath}</td>
</tr>
</table>
<h3>Request Authentication Information</h3>
<table border="1">
<tr>
<th class="name">Name</th>
<th class="value">Value</th>
</tr>
<tr>
<td class="name">Authorization Type</td>
<td>${request.authType}</td>
</tr>
<tr>
<td class="name">Remote User</td>
<td>${request.remoteUser}</td>
</tr>
<tr>
<td class="name">User Principal</td>
<td>${request.userPrincipal}</td>
</tr>
</table>
<!--
* Response Object
-->
<h2>Response Information</h2>
<table border="1">
<tr>
<th class="name">Name</th>
<th class="value">Value</th>
</tr>
<tr>
<td class="name">Buffer Size</td>
<td>${response.bufferSize}</td>
</tr>
<tr>
<td class="name">Character Encoding</td>
<td>${response.characterEncoding}</td>
</tr>
<tr>
<td class="name">Committed</td>
<td>${response.committed}</td>
</tr>
<tr>
<td class="name">Locale</td>
<td>${response.locale}</td>
</tr>
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment