SlideShare a Scribd company logo
1 of 29
Download to read offline
Adobe Experience Manager
@GabrielWalt, Product Manager
Deep Dive into Sightly,

an open source templating language
Adobe Experience Manager
Specification and TCK open sourced to GitHub.

Reference implementation donated to Apache Sling.
Follow @sightlyio on Twitter.

http://docs.adobe.com/docs/en/aem/6-2/develop/sightly.html
Adobe Experience Manager
§ 1 Expression contexts
§ 2 Passing data to client libs
§ 3 Use statement
§ 4 Template & Call statements
§ 5 Parameters for sub-resources
Adobe Experience Manager
The context option offers control over escaping and XSS protection.
Allowing some HTML markup (filtering out scripts)

<div>${properties.jcr:description @ context='html'}</div>
Adding URI validation protection to other attributes than src or href

<p data-link="${link @ context='uri'}">text</p>
Display Context Option
Adobe Experience Manager
Most useful contexts and what they do:
number XSSAPI.getValidNumber
uri XSSAPI.getValidHref (default for src and href attributes)
attribute XSSAPI.encodeForHTMLAttribute (default for other attributes)
text XSSAPI.encodeForHTML (default for element content)
scriptString XSSAPI.encodeForJSString
styleString XSSAPI.encodeForCSSString
html XSSAPI.filterHTML
unsafe disables all protection, use at your own risk.
Display Context Option
<a href="${myLink}" title="${myTitle}">${myContent}</a>

<script> var foo = "${myVar @ context='scriptString'}"; </string>

<style> a { font-family: "${myFont @ context='styleString'}"; } </style>
safer
Adobe Experience Manager
Preferred method for each context:
– src and href attributes: number, uri, attribute, unsafe
– other attributes: number, uri, attribute, unsafe
– element content: number, text, html, unsafe
– JS scripts
⊛
: number, uri, scriptString, unsafe
– CSS styles
⊛
: number, uri, styleString, unsafe

⊛ An explicit context is required for script and style contexts.

Don’t set the context manually unless you understand what you are doing.
Display Context Option
<a href="${myLink}" title="${myTitle}">${myContent}</a>

<script> var foo = "${myVar @ context='scriptString'}"; </string>

<style> a { font-family: "${myFont @ context='styleString'}"; } </style>
Adobe Experience Manager
§ 1 Expression contexts
§ 2 Passing data to client libs
§ 3 Use statement
§ 4 Template & Call statements
§ 5 Parameters for sub-resources
Adobe Experience Manager
<!-- template.html -->

<div data-sly-use.logic="logic.js"

data-json="${logic.json}"></div>
/* logic.js */

use(function () {

return {

json: JSON.stringify({

foo: "bar",

arr: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

})

};

});
Passing data to client libs
Adobe Experience Manager
<!-- template.html -->

<script id="my-handlebar-template"

type="text/x-handlebars-template"

data-sly-include="handlebar.html"></script>
<!-- handlebar.html -->

<p>${properties.jcr:title}</p>
Server-side JavaScript logic
Adobe Experience Manager
http://bit.ly/sightly-data-json
http://bit.ly/sightly-script-angular
Passing data to client libraries
Adobe Experience Manager
§ 1 Expression contexts
§ 2 Passing data to client libs
§ 3 Use statement
§ 4 Template & Call statements
§ 5 Parameters for sub-resources
Adobe Experience Manager
Initializes a helper object.

<div data-sly-use.logic="logic.js">${logic.hi}</div>
Output:

<div>Hello World</div>








Use Statement
Adobe Experience Manager
<!-- template.html -->

<div data-sly-use.logic="logic.js">${logic.hi}</div>
/* logic.js */

use(function () {

return {

hi: "Hello World"

};

});
Like for the Sightly template, the objects available in the logic file are
the same ones as in JSP with global.jsp
Server-side JavaScript logic
Adobe Experience Manager
<!-- template.html -->

<div data-sly-use.logic="Logic">${logic.hi}</div>
/* Logic.java in component */

package apps.my_site.components.my_component;

import org.sling…sightly.WCMUsePojo;
public class Logic extends WCMUsePojo {

private String hi;
@Override

public void activate() throws Exception {

hi = "Hello World";

}
public String getHi() {

return hi;

}

}
Javalogic
When the Java files are
located in the content
repository, next to the
Sightly template, only
the class name is
needed.
POJOextendingWCMUse
Adobe Experience Manager
<!-- template.html -->

<div data-sly-use.logic="com.foo.Logic">${logic.hi}</div>
/* Logic.java in OSGi bundle */

package com.foo;

import javax.annotation.PostConstruct;

import org.apache.sling.api.resource.Resource;

import org.apache.sling.models.annotations.Model;
@Model(adaptables = Resource.class)

public class Logic {

private String hi;
@PostConstruct

protected void init() {

hi = "Hello World";

}
public String getHi() {

return hi;

}

}
Javalogic
AdaptablewithSlingModels When embedded in 

an OSGi bundle, the
fully qualified Java class
name is needed.
The Use-API accepts classes that are
adaptable from Resource or Request.
Adobe Experience Manager
Model logic

This logic is not tied to a template and is potentially reusable among components.

It should aim to form a stable API that changes little, even in case of a full redesign.
➔ Java located in OSGi bundle
View logic

This logic is specific to the templates and is likely to change if the design changes.

It is thus a good practice to locate it in the content repository, next to the template.
➔ JavaScript located in component 

If components are to be maintained by front-end devs (typically with Brackets).
➔ Java located in component

If performance is critical (e.g. when many requests are not cached by the dispatcher).
What kind of Use-API?
Adobe Experience Manager
Start simple: first, no code!
OSGi (Model)
Resource
API
Page
API
Content Repository
Component (View)Content Structure
sling:
resourceType
Resource Template
– Sling plays the role of the controller
and resolves the sling:resourceType,
deciding which component will
render the accessed resource.
– The component plays the role of the
view and it’s Sightly template builds
the corresponding markup.
– The Resource and Page APIs play the
role of the model, which are available
from the template as variables.
Adobe Experience Manager
Add logic only where needed
– Model Logic is
needed only if the
logic to access the
data is different to
what existing APIs
provide.
– View Logic is
needed only when
the template needs
additional data
preparation.
OSGi (Model)
Resource
API
Page
API
Model Logic
Content Repository
Component (View)Content Structure
sling:
resourceType data-sly-use
Resource Template View Logic
Adobe Experience Manager
The logic can access the same variables than exist in the template.
JavaScript:

var title = properties.get("title");
Java extending WCMUse:

String title = getProperties().get("title", String.class);
Java with SlingModels:

@Inject @Optional

private String title;
Use-API Bindings
Adobe Experience Manager
With the same notation as for template parameters, named
parameters can be passed to the Use-API.

<a data-sly-use.ext="${'Externalize' @ path='page.html'}"

href="${ext.absolutePath}">link</a>
Output:

<a href="/absolute/path/to/page.html">link</a>
Don’t pass variables that are part of the global binding (like properties
or resource) as they can be accessed from the logic too.
Use-API Parameters
Adobe Experience Manager
These parameters can then be read in from the various Use-API.
JavaScript:

var path = this.path;
Java extending WCMUse:

String path = get("path", String.class);
Java with SlingModels (works only when adapting from Request):

@Inject @Optional

private String path;
Use-API Parameters
Adobe Experience Manager
The use statement can also load data-sly-template markup
snippets located in other files.

<!-- library.html -->

<template data-sly-template.foo="${@ text}">

<span class="example">${text}</span>

</template>
<!-- template.html -->

<div data-sly-use.library="library.html"

data-sly-call="${library.foo @ text='Hi'}"></div>
Output:

<div><span class="example">Hi</span></div>
Use with Template & Call
Adobe Experience Manager
§ 1 Expression contexts
§ 2 Passing data to client libs
§ 3 Use statement
§ 4 Template & Call statements
§ 5 Parameters for sub-resources
Adobe Experience Manager
Declare and call a markup snippet with named parameters.

<template data-sly-template.foo="${@ class, text}">

<span class="${class}">${text}</span>

</template>
<div data-sly-call="${foo @ class='example',

text='Hi'}"></div>
Output:

<div><span class="example">Hi</span></div>
Template & Call Statements
Defining template parametersDeclaring template name
Template content
Calling template by name
Passing named parameters
Adobe Experience Manager
Advanced example of a recursive site map with template, call and list.

<ol data-sly-template.listChildren="${@ page}"

data-sly-list="${page.listChildren}">

<li>

<div class="title">${item.title}</div>

<ol data-sly-call="${listChildren @ page=item}"></ol>

</li>

</ol>
<ol data-sly-call="${listChildren @ page=currentPage}"></ol>
Template & Call Statements
Adobe Experience Manager
§ 1 Expression contexts
§ 2 Passing data to client libs
§ 3 Use statement
§ 4 Template & Call statements
§ 5 Parameters for sub-resources
Adobe Experience Manager
http://bit.ly/sightly-attributes
http://bit.ly/sightly-synthetic
Parameters for sub-resources
Adobe Experience Manager
Thank you!
• Documentation

https://docs.adobe.com/docs/en/aem/6-2/develop/sightly.html
• Specification

https://github.com/Adobe-Marketing-Cloud/sightly-spec
• REPL (Read-Eval-Print Loop) live Sightly execution environment

https://github.com/Adobe-Marketing-Cloud/aem-sightly-repl

@GabrielWalt, Product Manager
AEM Sightly Deep Dive

More Related Content

What's hot

Sling models by Justin Edelson
Sling models by Justin Edelson Sling models by Justin Edelson
Sling models by Justin Edelson AEM HUB
 
JCR, Sling or AEM? Which API should I use and when?
JCR, Sling or AEM? Which API should I use and when?JCR, Sling or AEM? Which API should I use and when?
JCR, Sling or AEM? Which API should I use and when?connectwebex
 
Understanding Sling Models in AEM
Understanding Sling Models in AEMUnderstanding Sling Models in AEM
Understanding Sling Models in AEMAccunity Software
 
Dynamic components using SPA concepts in AEM
Dynamic components using SPA concepts in AEMDynamic components using SPA concepts in AEM
Dynamic components using SPA concepts in AEMBojana Popovska
 
AEM and Sling
AEM and SlingAEM and Sling
AEM and SlingLo Ki
 
AEM (CQ) Dispatcher Security and CDN+Browser Caching
AEM (CQ) Dispatcher Security and CDN+Browser CachingAEM (CQ) Dispatcher Security and CDN+Browser Caching
AEM (CQ) Dispatcher Security and CDN+Browser CachingAndrew Khoury
 
Adobe Experience Manager Core Components
Adobe Experience Manager Core ComponentsAdobe Experience Manager Core Components
Adobe Experience Manager Core ComponentsGabriel Walt
 
A Hacker's perspective on AEM applications security
A Hacker's perspective on AEM applications securityA Hacker's perspective on AEM applications security
A Hacker's perspective on AEM applications securityMikhail Egorov
 
AEM Rich Text Editor (RTE) Deep Dive
AEM Rich Text Editor (RTE) Deep DiveAEM Rich Text Editor (RTE) Deep Dive
AEM Rich Text Editor (RTE) Deep DiveHanish Bansal
 
AEM & eCommerce integration
AEM & eCommerce integrationAEM & eCommerce integration
AEM & eCommerce integrationLokesh BS
 
The secret life of a dispatcher (Adobe CQ AEM)
The secret life of a dispatcher (Adobe CQ AEM)The secret life of a dispatcher (Adobe CQ AEM)
The secret life of a dispatcher (Adobe CQ AEM)Venugopal Gummadala
 
AEM & Single Page Applications (SPAs) 101
AEM & Single Page Applications (SPAs) 101AEM & Single Page Applications (SPAs) 101
AEM & Single Page Applications (SPAs) 101Adobe
 
Spring Framework - Spring Security
Spring Framework - Spring SecuritySpring Framework - Spring Security
Spring Framework - Spring SecurityDzmitry Naskou
 
How to implement internationalization (i18n) in angular application(multiple ...
How to implement internationalization (i18n) in angular application(multiple ...How to implement internationalization (i18n) in angular application(multiple ...
How to implement internationalization (i18n) in angular application(multiple ...Katy Slemon
 
SPA Editor - Adobe Experience Manager Sites
SPA Editor - Adobe Experience Manager SitesSPA Editor - Adobe Experience Manager Sites
SPA Editor - Adobe Experience Manager SitesGabriel Walt
 

What's hot (20)

Sling models by Justin Edelson
Sling models by Justin Edelson Sling models by Justin Edelson
Sling models by Justin Edelson
 
JCR, Sling or AEM? Which API should I use and when?
JCR, Sling or AEM? Which API should I use and when?JCR, Sling or AEM? Which API should I use and when?
JCR, Sling or AEM? Which API should I use and when?
 
Understanding Sling Models in AEM
Understanding Sling Models in AEMUnderstanding Sling Models in AEM
Understanding Sling Models in AEM
 
Sling Models Overview
Sling Models OverviewSling Models Overview
Sling Models Overview
 
Dynamic components using SPA concepts in AEM
Dynamic components using SPA concepts in AEMDynamic components using SPA concepts in AEM
Dynamic components using SPA concepts in AEM
 
Osgi
OsgiOsgi
Osgi
 
AEM and Sling
AEM and SlingAEM and Sling
AEM and Sling
 
AEM (CQ) Dispatcher Security and CDN+Browser Caching
AEM (CQ) Dispatcher Security and CDN+Browser CachingAEM (CQ) Dispatcher Security and CDN+Browser Caching
AEM (CQ) Dispatcher Security and CDN+Browser Caching
 
Adobe Experience Manager Core Components
Adobe Experience Manager Core ComponentsAdobe Experience Manager Core Components
Adobe Experience Manager Core Components
 
CSS Best practice
CSS Best practiceCSS Best practice
CSS Best practice
 
A Hacker's perspective on AEM applications security
A Hacker's perspective on AEM applications securityA Hacker's perspective on AEM applications security
A Hacker's perspective on AEM applications security
 
AEM - Client Libraries
AEM - Client LibrariesAEM - Client Libraries
AEM - Client Libraries
 
AEM Rich Text Editor (RTE) Deep Dive
AEM Rich Text Editor (RTE) Deep DiveAEM Rich Text Editor (RTE) Deep Dive
AEM Rich Text Editor (RTE) Deep Dive
 
AEM & eCommerce integration
AEM & eCommerce integrationAEM & eCommerce integration
AEM & eCommerce integration
 
The secret life of a dispatcher (Adobe CQ AEM)
The secret life of a dispatcher (Adobe CQ AEM)The secret life of a dispatcher (Adobe CQ AEM)
The secret life of a dispatcher (Adobe CQ AEM)
 
slingmodels
slingmodelsslingmodels
slingmodels
 
AEM & Single Page Applications (SPAs) 101
AEM & Single Page Applications (SPAs) 101AEM & Single Page Applications (SPAs) 101
AEM & Single Page Applications (SPAs) 101
 
Spring Framework - Spring Security
Spring Framework - Spring SecuritySpring Framework - Spring Security
Spring Framework - Spring Security
 
How to implement internationalization (i18n) in angular application(multiple ...
How to implement internationalization (i18n) in angular application(multiple ...How to implement internationalization (i18n) in angular application(multiple ...
How to implement internationalization (i18n) in angular application(multiple ...
 
SPA Editor - Adobe Experience Manager Sites
SPA Editor - Adobe Experience Manager SitesSPA Editor - Adobe Experience Manager Sites
SPA Editor - Adobe Experience Manager Sites
 

Viewers also liked

The six key steps to AEM architecture
The six key steps to AEM architectureThe six key steps to AEM architecture
The six key steps to AEM architectureAshokkumar T A
 
AEM (CQ) Dispatcher Caching Webinar 2013
AEM (CQ) Dispatcher Caching Webinar 2013AEM (CQ) Dispatcher Caching Webinar 2013
AEM (CQ) Dispatcher Caching Webinar 2013Andrew Khoury
 
Build single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMBuild single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMconnectwebex
 
Sling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak KhetawatSling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak KhetawatAEM HUB
 
So how do I test my Sling application?
 So how do I test my Sling application? So how do I test my Sling application?
So how do I test my Sling application?Robert Munteanu
 
Three WEM Dev Tricks
Three WEM Dev TricksThree WEM Dev Tricks
Three WEM Dev TricksGabriel Walt
 
Web Apps atop a Content Repository
Web Apps atop a Content RepositoryWeb Apps atop a Content Repository
Web Apps atop a Content RepositoryGabriel Walt
 
Sling Component Filters in CQ5
Sling Component Filters in CQ5 Sling Component Filters in CQ5
Sling Component Filters in CQ5 connectwebex
 
Continous Delivery with CQ
Continous Delivery with CQContinous Delivery with CQ
Continous Delivery with CQolibur
 
Dynamic Components using Single-Page-Application Concepts in AEM/CQ
Dynamic Components using Single-Page-Application Concepts in AEM/CQDynamic Components using Single-Page-Application Concepts in AEM/CQ
Dynamic Components using Single-Page-Application Concepts in AEM/CQNetcetera
 
Do more with LESS, Handlebars, Coffeescript and other Web Resources in AEM
Do more with LESS, Handlebars, Coffeescript and other Web Resources in AEMDo more with LESS, Handlebars, Coffeescript and other Web Resources in AEM
Do more with LESS, Handlebars, Coffeescript and other Web Resources in AEMBob Paulin
 
User Interface customization for AEM 6
User Interface customization for AEM 6User Interface customization for AEM 6
User Interface customization for AEM 6Damien Antipa
 
AEM 6.1 User Interface Customization
AEM 6.1 User Interface CustomizationAEM 6.1 User Interface Customization
AEM 6.1 User Interface CustomizationChristian Meyer
 

Viewers also liked (18)

The six key steps to AEM architecture
The six key steps to AEM architectureThe six key steps to AEM architecture
The six key steps to AEM architecture
 
AEM (CQ) Dispatcher Caching Webinar 2013
AEM (CQ) Dispatcher Caching Webinar 2013AEM (CQ) Dispatcher Caching Webinar 2013
AEM (CQ) Dispatcher Caching Webinar 2013
 
Build single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEMBuild single page applications using AngularJS on AEM
Build single page applications using AngularJS on AEM
 
Sling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak KhetawatSling Models Using Sightly and JSP by Deepak Khetawat
Sling Models Using Sightly and JSP by Deepak Khetawat
 
EVOLVE'14 | Enhance | Gabriel Walt | Sightly Component Development
EVOLVE'14 | Enhance | Gabriel Walt | Sightly Component DevelopmentEVOLVE'14 | Enhance | Gabriel Walt | Sightly Component Development
EVOLVE'14 | Enhance | Gabriel Walt | Sightly Component Development
 
So how do I test my Sling application?
 So how do I test my Sling application? So how do I test my Sling application?
So how do I test my Sling application?
 
Three WEM Dev Tricks
Three WEM Dev TricksThree WEM Dev Tricks
Three WEM Dev Tricks
 
Web Apps atop a Content Repository
Web Apps atop a Content RepositoryWeb Apps atop a Content Repository
Web Apps atop a Content Repository
 
EVOLVE'16 | Enhance | Oscar Bolaños & Justin Edelson | Search All the Things:...
EVOLVE'16 | Enhance | Oscar Bolaños & Justin Edelson | Search All the Things:...EVOLVE'16 | Enhance | Oscar Bolaños & Justin Edelson | Search All the Things:...
EVOLVE'16 | Enhance | Oscar Bolaños & Justin Edelson | Search All the Things:...
 
Sling Component Filters in CQ5
Sling Component Filters in CQ5 Sling Component Filters in CQ5
Sling Component Filters in CQ5
 
Continous Delivery with CQ
Continous Delivery with CQContinous Delivery with CQ
Continous Delivery with CQ
 
Dynamic Components using Single-Page-Application Concepts in AEM/CQ
Dynamic Components using Single-Page-Application Concepts in AEM/CQDynamic Components using Single-Page-Application Concepts in AEM/CQ
Dynamic Components using Single-Page-Application Concepts in AEM/CQ
 
Aem best practices
Aem best practicesAem best practices
Aem best practices
 
Do more with LESS, Handlebars, Coffeescript and other Web Resources in AEM
Do more with LESS, Handlebars, Coffeescript and other Web Resources in AEMDo more with LESS, Handlebars, Coffeescript and other Web Resources in AEM
Do more with LESS, Handlebars, Coffeescript and other Web Resources in AEM
 
EVOLVE'16 | Deploy | Abhishek Dwevedi | Understanding a Typical AEM Deployment
EVOLVE'16 | Deploy | Abhishek Dwevedi | Understanding a Typical AEM DeploymentEVOLVE'16 | Deploy | Abhishek Dwevedi | Understanding a Typical AEM Deployment
EVOLVE'16 | Deploy | Abhishek Dwevedi | Understanding a Typical AEM Deployment
 
User Interface customization for AEM 6
User Interface customization for AEM 6User Interface customization for AEM 6
User Interface customization for AEM 6
 
AEM 6.1 User Interface Customization
AEM 6.1 User Interface CustomizationAEM 6.1 User Interface Customization
AEM 6.1 User Interface Customization
 
EVOLVE'16 | Enhance | Anil Kalbag & Anshul Chhabra | Comparative Architecture...
EVOLVE'16 | Enhance | Anil Kalbag & Anshul Chhabra | Comparative Architecture...EVOLVE'16 | Enhance | Anil Kalbag & Anshul Chhabra | Comparative Architecture...
EVOLVE'16 | Enhance | Anil Kalbag & Anshul Chhabra | Comparative Architecture...
 

Similar to AEM Sightly Deep Dive

SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015Pushkar Chivate
 
Code igniter - A brief introduction
Code igniter - A brief introductionCode igniter - A brief introduction
Code igniter - A brief introductionCommit University
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_HourDilip Patel
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's CodeWildan Maulana
 
Modular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSModular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSGunnar Hillert
 
Spring 3 - Der dritte Frühling
Spring 3 - Der dritte FrühlingSpring 3 - Der dritte Frühling
Spring 3 - Der dritte FrühlingThorsten Kamann
 
PPT on javascript ajax and css and some points related to server
PPT on javascript ajax and css and some points related to serverPPT on javascript ajax and css and some points related to server
PPT on javascript ajax and css and some points related to servershivanichourasia01
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Mack Hardy
 
jQuery Tips Tricks Trivia
jQuery Tips Tricks TriviajQuery Tips Tricks Trivia
jQuery Tips Tricks TriviaCognizant
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalystdwm042
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Phpfunkatron
 
IRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHPIRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHPIRJET Journal
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Tuna Tore
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892Tuna Tore
 
Get things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGet things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGiuliano Iacobelli
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSmurtazahaveliwala
 

Similar to AEM Sightly Deep Dive (20)

SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015SharePoint Saturday Atlanta 2015
SharePoint Saturday Atlanta 2015
 
Code igniter - A brief introduction
Code igniter - A brief introductionCode igniter - A brief introduction
Code igniter - A brief introduction
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's Code
 
Modular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJSModular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJS
 
Spring 3 - Der dritte Frühling
Spring 3 - Der dritte FrühlingSpring 3 - Der dritte Frühling
Spring 3 - Der dritte Frühling
 
PPT on javascript ajax and css and some points related to server
PPT on javascript ajax and css and some points related to serverPPT on javascript ajax and css and some points related to server
PPT on javascript ajax and css and some points related to server
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
 
jQuery Tips Tricks Trivia
jQuery Tips Tricks TriviajQuery Tips Tricks Trivia
jQuery Tips Tricks Trivia
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
 
IRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHPIRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHP
 
Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5Java Spring MVC Framework with AngularJS by Google and HTML5
Java Spring MVC Framework with AngularJS by Google and HTML5
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
 
Knolx session
Knolx sessionKnolx session
Knolx session
 
WebGUI Developers Workshop
WebGUI Developers WorkshopWebGUI Developers Workshop
WebGUI Developers Workshop
 
Get things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplicationsGet things done with Yii - quickly build webapplications
Get things done with Yii - quickly build webapplications
 
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSAngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJS
 
Php frameworks
Php frameworksPhp frameworks
Php frameworks
 

More from Gabriel Walt

Managing Omnichannel Experiences with Adobe Experience Manager (AEM)
Managing Omnichannel Experiences with Adobe Experience Manager (AEM)Managing Omnichannel Experiences with Adobe Experience Manager (AEM)
Managing Omnichannel Experiences with Adobe Experience Manager (AEM)Gabriel Walt
 
Modernizing Adobe Experience Manager (AEM)
Modernizing Adobe Experience Manager (AEM)Modernizing Adobe Experience Manager (AEM)
Modernizing Adobe Experience Manager (AEM)Gabriel Walt
 
CQ Provisionning & Authoring
CQ Provisionning & AuthoringCQ Provisionning & Authoring
CQ Provisionning & AuthoringGabriel Walt
 
Web, Mobile, App and Back!
Web, Mobile, App and Back!Web, Mobile, App and Back!
Web, Mobile, App and Back!Gabriel Walt
 
Optimizing HTML5 Sites with CQ5/WEM
Optimizing HTML5 Sites with CQ5/WEMOptimizing HTML5 Sites with CQ5/WEM
Optimizing HTML5 Sites with CQ5/WEMGabriel Walt
 

More from Gabriel Walt (8)

Managing Omnichannel Experiences with Adobe Experience Manager (AEM)
Managing Omnichannel Experiences with Adobe Experience Manager (AEM)Managing Omnichannel Experiences with Adobe Experience Manager (AEM)
Managing Omnichannel Experiences with Adobe Experience Manager (AEM)
 
Modernizing Adobe Experience Manager (AEM)
Modernizing Adobe Experience Manager (AEM)Modernizing Adobe Experience Manager (AEM)
Modernizing Adobe Experience Manager (AEM)
 
CQ Provisionning & Authoring
CQ Provisionning & AuthoringCQ Provisionning & Authoring
CQ Provisionning & Authoring
 
Web, Mobile, App and Back!
Web, Mobile, App and Back!Web, Mobile, App and Back!
Web, Mobile, App and Back!
 
Drive dam
Drive damDrive dam
Drive dam
 
Optimizing HTML5 Sites with CQ5/WEM
Optimizing HTML5 Sites with CQ5/WEMOptimizing HTML5 Sites with CQ5/WEM
Optimizing HTML5 Sites with CQ5/WEM
 
CQ 5.4 Deep-Dive
CQ 5.4 Deep-DiveCQ 5.4 Deep-Dive
CQ 5.4 Deep-Dive
 
Crx 2.2 Deep-Dive
Crx 2.2 Deep-DiveCrx 2.2 Deep-Dive
Crx 2.2 Deep-Dive
 

Recently uploaded

EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 

Recently uploaded (20)

EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 

AEM Sightly Deep Dive

  • 1. Adobe Experience Manager @GabrielWalt, Product Manager Deep Dive into Sightly,
 an open source templating language
  • 2. Adobe Experience Manager Specification and TCK open sourced to GitHub.
 Reference implementation donated to Apache Sling. Follow @sightlyio on Twitter.
 http://docs.adobe.com/docs/en/aem/6-2/develop/sightly.html
  • 3. Adobe Experience Manager § 1 Expression contexts § 2 Passing data to client libs § 3 Use statement § 4 Template & Call statements § 5 Parameters for sub-resources
  • 4. Adobe Experience Manager The context option offers control over escaping and XSS protection. Allowing some HTML markup (filtering out scripts)
 <div>${properties.jcr:description @ context='html'}</div> Adding URI validation protection to other attributes than src or href
 <p data-link="${link @ context='uri'}">text</p> Display Context Option
  • 5. Adobe Experience Manager Most useful contexts and what they do: number XSSAPI.getValidNumber uri XSSAPI.getValidHref (default for src and href attributes) attribute XSSAPI.encodeForHTMLAttribute (default for other attributes) text XSSAPI.encodeForHTML (default for element content) scriptString XSSAPI.encodeForJSString styleString XSSAPI.encodeForCSSString html XSSAPI.filterHTML unsafe disables all protection, use at your own risk. Display Context Option <a href="${myLink}" title="${myTitle}">${myContent}</a>
 <script> var foo = "${myVar @ context='scriptString'}"; </string>
 <style> a { font-family: "${myFont @ context='styleString'}"; } </style> safer
  • 6. Adobe Experience Manager Preferred method for each context: – src and href attributes: number, uri, attribute, unsafe – other attributes: number, uri, attribute, unsafe – element content: number, text, html, unsafe – JS scripts ⊛ : number, uri, scriptString, unsafe – CSS styles ⊛ : number, uri, styleString, unsafe
 ⊛ An explicit context is required for script and style contexts.
 Don’t set the context manually unless you understand what you are doing. Display Context Option <a href="${myLink}" title="${myTitle}">${myContent}</a>
 <script> var foo = "${myVar @ context='scriptString'}"; </string>
 <style> a { font-family: "${myFont @ context='styleString'}"; } </style>
  • 7. Adobe Experience Manager § 1 Expression contexts § 2 Passing data to client libs § 3 Use statement § 4 Template & Call statements § 5 Parameters for sub-resources
  • 8. Adobe Experience Manager <!-- template.html -->
 <div data-sly-use.logic="logic.js"
 data-json="${logic.json}"></div> /* logic.js */
 use(function () {
 return {
 json: JSON.stringify({
 foo: "bar",
 arr: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
 })
 };
 }); Passing data to client libs
  • 9. Adobe Experience Manager <!-- template.html -->
 <script id="my-handlebar-template"
 type="text/x-handlebars-template"
 data-sly-include="handlebar.html"></script> <!-- handlebar.html -->
 <p>${properties.jcr:title}</p> Server-side JavaScript logic
  • 11. Adobe Experience Manager § 1 Expression contexts § 2 Passing data to client libs § 3 Use statement § 4 Template & Call statements § 5 Parameters for sub-resources
  • 12. Adobe Experience Manager Initializes a helper object.
 <div data-sly-use.logic="logic.js">${logic.hi}</div> Output:
 <div>Hello World</div> 
 
 
 
 Use Statement
  • 13. Adobe Experience Manager <!-- template.html -->
 <div data-sly-use.logic="logic.js">${logic.hi}</div> /* logic.js */
 use(function () {
 return {
 hi: "Hello World"
 };
 }); Like for the Sightly template, the objects available in the logic file are the same ones as in JSP with global.jsp Server-side JavaScript logic
  • 14. Adobe Experience Manager <!-- template.html -->
 <div data-sly-use.logic="Logic">${logic.hi}</div> /* Logic.java in component */
 package apps.my_site.components.my_component;
 import org.sling…sightly.WCMUsePojo; public class Logic extends WCMUsePojo {
 private String hi; @Override
 public void activate() throws Exception {
 hi = "Hello World";
 } public String getHi() {
 return hi;
 }
 } Javalogic When the Java files are located in the content repository, next to the Sightly template, only the class name is needed. POJOextendingWCMUse
  • 15. Adobe Experience Manager <!-- template.html -->
 <div data-sly-use.logic="com.foo.Logic">${logic.hi}</div> /* Logic.java in OSGi bundle */
 package com.foo;
 import javax.annotation.PostConstruct;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.models.annotations.Model; @Model(adaptables = Resource.class)
 public class Logic {
 private String hi; @PostConstruct
 protected void init() {
 hi = "Hello World";
 } public String getHi() {
 return hi;
 }
 } Javalogic AdaptablewithSlingModels When embedded in 
 an OSGi bundle, the fully qualified Java class name is needed. The Use-API accepts classes that are adaptable from Resource or Request.
  • 16. Adobe Experience Manager Model logic
 This logic is not tied to a template and is potentially reusable among components.
 It should aim to form a stable API that changes little, even in case of a full redesign. ➔ Java located in OSGi bundle View logic
 This logic is specific to the templates and is likely to change if the design changes.
 It is thus a good practice to locate it in the content repository, next to the template. ➔ JavaScript located in component 
 If components are to be maintained by front-end devs (typically with Brackets). ➔ Java located in component
 If performance is critical (e.g. when many requests are not cached by the dispatcher). What kind of Use-API?
  • 17. Adobe Experience Manager Start simple: first, no code! OSGi (Model) Resource API Page API Content Repository Component (View)Content Structure sling: resourceType Resource Template – Sling plays the role of the controller and resolves the sling:resourceType, deciding which component will render the accessed resource. – The component plays the role of the view and it’s Sightly template builds the corresponding markup. – The Resource and Page APIs play the role of the model, which are available from the template as variables.
  • 18. Adobe Experience Manager Add logic only where needed – Model Logic is needed only if the logic to access the data is different to what existing APIs provide. – View Logic is needed only when the template needs additional data preparation. OSGi (Model) Resource API Page API Model Logic Content Repository Component (View)Content Structure sling: resourceType data-sly-use Resource Template View Logic
  • 19. Adobe Experience Manager The logic can access the same variables than exist in the template. JavaScript:
 var title = properties.get("title"); Java extending WCMUse:
 String title = getProperties().get("title", String.class); Java with SlingModels:
 @Inject @Optional
 private String title; Use-API Bindings
  • 20. Adobe Experience Manager With the same notation as for template parameters, named parameters can be passed to the Use-API.
 <a data-sly-use.ext="${'Externalize' @ path='page.html'}"
 href="${ext.absolutePath}">link</a> Output:
 <a href="/absolute/path/to/page.html">link</a> Don’t pass variables that are part of the global binding (like properties or resource) as they can be accessed from the logic too. Use-API Parameters
  • 21. Adobe Experience Manager These parameters can then be read in from the various Use-API. JavaScript:
 var path = this.path; Java extending WCMUse:
 String path = get("path", String.class); Java with SlingModels (works only when adapting from Request):
 @Inject @Optional
 private String path; Use-API Parameters
  • 22. Adobe Experience Manager The use statement can also load data-sly-template markup snippets located in other files.
 <!-- library.html -->
 <template data-sly-template.foo="${@ text}">
 <span class="example">${text}</span>
 </template> <!-- template.html -->
 <div data-sly-use.library="library.html"
 data-sly-call="${library.foo @ text='Hi'}"></div> Output:
 <div><span class="example">Hi</span></div> Use with Template & Call
  • 23. Adobe Experience Manager § 1 Expression contexts § 2 Passing data to client libs § 3 Use statement § 4 Template & Call statements § 5 Parameters for sub-resources
  • 24. Adobe Experience Manager Declare and call a markup snippet with named parameters.
 <template data-sly-template.foo="${@ class, text}">
 <span class="${class}">${text}</span>
 </template> <div data-sly-call="${foo @ class='example',
 text='Hi'}"></div> Output:
 <div><span class="example">Hi</span></div> Template & Call Statements Defining template parametersDeclaring template name Template content Calling template by name Passing named parameters
  • 25. Adobe Experience Manager Advanced example of a recursive site map with template, call and list.
 <ol data-sly-template.listChildren="${@ page}"
 data-sly-list="${page.listChildren}">
 <li>
 <div class="title">${item.title}</div>
 <ol data-sly-call="${listChildren @ page=item}"></ol>
 </li>
 </ol> <ol data-sly-call="${listChildren @ page=currentPage}"></ol> Template & Call Statements
  • 26. Adobe Experience Manager § 1 Expression contexts § 2 Passing data to client libs § 3 Use statement § 4 Template & Call statements § 5 Parameters for sub-resources
  • 28. Adobe Experience Manager Thank you! • Documentation
 https://docs.adobe.com/docs/en/aem/6-2/develop/sightly.html • Specification
 https://github.com/Adobe-Marketing-Cloud/sightly-spec • REPL (Read-Eval-Print Loop) live Sightly execution environment
 https://github.com/Adobe-Marketing-Cloud/aem-sightly-repl
 @GabrielWalt, Product Manager