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
 
HTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowHTL(Sightly) - All you need to know
HTL(Sightly) - All you need to know
Prabhdeep Singh
 
Rest and Sling Resolution
Rest and Sling ResolutionRest and Sling Resolution
Rest and Sling Resolution
DEEPAK KHETAWAT
 
Basics of Solr and Solr Integration with AEM6
Basics of Solr and Solr Integration with AEM6Basics of Solr and Solr Integration with AEM6
Basics of Solr and Solr Integration with AEM6
DEEPAK KHETAWAT
 

What's hot (20)

Sling models by Justin Edelson
Sling models by Justin Edelson Sling models by Justin Edelson
Sling models by Justin Edelson
 
HTL(Sightly) - All you need to know
HTL(Sightly) - All you need to knowHTL(Sightly) - All you need to know
HTL(Sightly) - All you need to know
 
Introduction to Sightly
Introduction to SightlyIntroduction to Sightly
Introduction to Sightly
 
Rest and Sling Resolution
Rest and Sling ResolutionRest and Sling Resolution
Rest and Sling Resolution
 
Adobe Experience Manager Core Components
Adobe Experience Manager Core ComponentsAdobe Experience Manager Core Components
Adobe Experience Manager Core Components
 
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
 
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
 
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
 
slingmodels
slingmodelsslingmodels
slingmodels
 
AEM - Client Libraries
AEM - Client LibrariesAEM - Client Libraries
AEM - Client Libraries
 
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?
 
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
 
Adobe AEM core components
Adobe AEM core componentsAdobe AEM core components
Adobe AEM core components
 
Mastering the Sling Rewriter
Mastering the Sling RewriterMastering the Sling Rewriter
Mastering the Sling Rewriter
 
Modernising AEM Sites Codebase (AEM Meetup 2019)
Modernising AEM Sites Codebase  (AEM Meetup 2019)Modernising AEM Sites Codebase  (AEM Meetup 2019)
Modernising AEM Sites Codebase (AEM Meetup 2019)
 
Basics of Solr and Solr Integration with AEM6
Basics of Solr and Solr Integration with AEM6Basics of Solr and Solr Integration with AEM6
Basics of Solr and Solr Integration with AEM6
 
Experience and Content Fragment
Experience and Content FragmentExperience and Content Fragment
Experience and Content Fragment
 
Third party libraries and OSGi - a complicated relationship
Third party libraries and OSGi - a complicated relationshipThird party libraries and OSGi - a complicated relationship
Third party libraries and OSGi - a complicated relationship
 
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)
 
Osgi
OsgiOsgi
Osgi
 

Viewers also liked

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
connectwebex
 
Three WEM Dev Tricks
Three WEM Dev TricksThree WEM Dev Tricks
Three WEM Dev Tricks
Gabriel Walt
 

Viewers also liked (17)

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
 
Aem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricks
 
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

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_Hour
Dilip Patel
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
funkatron
 
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
Tuna Tore
 
springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892springmvc-150923124312-lva1-app6892
springmvc-150923124312-lva1-app6892
Tuna Tore
 

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

More from Gabriel Walt (8)

Modernizing Adobe Experience Manager (AEM)
Modernizing Adobe Experience Manager (AEM)Modernizing Adobe Experience Manager (AEM)
Modernizing Adobe Experience Manager (AEM)
 
SPA Editor - Adobe Experience Manager Sites
SPA Editor - Adobe Experience Manager SitesSPA Editor - Adobe Experience Manager Sites
SPA Editor - Adobe Experience Manager Sites
 
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

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
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...
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 

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