Professional Documents
Culture Documents
All Sightly expressions are delimited by ${ } at runtime the values found in the {} are evaluated and injected into the HTML stream. The values
can be literals, variables, operators and options:
Return Current Page
Escape Character String
String Formatting
Array Join
Accessing Object properties
Accessing properties with colons
Accessing properties with special
characters (i.e. Space)
Accessing variables
If used within a Scripting Tag, the Context
option is mandatory
<div>Page: ${currentPage.name}</div>
${'it\'s great'}
${Page {0} of {1} @ format=[current, total]}
${[one, to] @join=;{
${properties.text}
${properties.jcr:title}
${properties[my property]}
${properties[myVar]}
<script> trackID=${id @ context=scriptingString};</script>
All Sightly data attributes are based on HTML5 data Attribute syntax. All Sightly specific attributes are prefixed with data-slyTest attribute
data-sly-test
Test if a value is true or false
If this is true show the tag line, else remove the
Host element
Text attribute
data-sly-text
Replace the Text if a value is true or false
If this is true show the tag line, else do not
<div data-sly-use.nav=navigation.js>${nav.foo}</div>
<div data-sly-use.nav="org.example.Navigation">${nav.foo}
</div> <!-- as OSGI Bundle -->
<div data-sly-use.nav="Navigation">${nav.foo}</div>
<!-- as Source file in same folder. Use ClassName global to the Sight
file -->
<div data-sly-resource="${@path='par',
resourceType='foundation/components/parsys'}"></div>
Include attribute
Include other files (equivalent to the
cq:include tag)
<div data-sly-include=/libs/wcm/core/components/init/
init.jsp>
Attribute attribute
Adds attributes to the host element
Attribute attribute
Use an array to make things easy
attrMap = {
title: "myTitle",
class: "myClass",
id: "myId"
}
<div data-sly-attribute="${attrMap}"></div>
<!will produce
<h1 data-sly-element="${titleLevel}">text</h1>
Element attribute
Replaces the element of the host element <!will produce <titleLevel></titleLevel> -->
For security sakes, only works with certain ta
Unwrap attribute
Remove the outer elements (i.e. HTML
Tags) leaving just the output of the
Expression)
Operators Not, And, Or, Conditional, Comparison and Grouping of operators are supported
Not
And
Or
Conditional
Comparison
${!var}
Grouping
${myVar @ optOne}
${myVar @ optOne, optTwo=bar}
${@ optOne, optTwo=bar}
Access to a set of Standard objects and there properties/methods. If required, van use the data-sly-list attribute
Variable Name
Description
properties
pageProperties
inheritedPageProperties
Variable Name
Description
component
com.day.cq.wcm.api.components.Component
componentContext
com.day.cq.wcm.api.components.ComponentContext
currentDesign
com.day.cq.wcm.api.designer.Design
currentNode
javax.jcr.Node
currentPage
com.day.cq.wcm.api.Page
currentSession
javax.servlet.http.HttpSession
currentStyle
com.day.cq.wcm.api.designer.Style
designer
com.day.cq.wcm.api.designer.Designer
editContext
com.day.cq.wcm.api.components.EditContext
log
org.slf4j.Logger
out
java.io.PrintWriter
pageManager
com.day.cq.wcm.api.PageManager
reader
java.io.BufferedReader
request
org.apache.sling.api.SlingHttpServletRequest
resource
org.apache.sling.api.resource.Resource
resourceDesign
com.day.cq.wcm.api.designer.Design
resourcePage
com.day.cq.wcm.api.Page
response
org.apache.sling.api.SlingHttpServletResponse
sling
org.apache.sling.api.scripting.SlingScriptHelper
slyWcmHelper
com.adobe.cq.sightly.WCMScriptHelper
wcmmode
xssAPI
com.adobe.granite.xss.impl.XSSAPImpl