SlideShare a Scribd company logo
www.tothenew.com
HTML Template Language
www.tothenew.com
Agenda
● What is HTL?
● Why HTL?
● Global Objects
● HTL Block Statements
● HTL Use-API
● HTL Expression Options
● Best Practises
www.tothenew.com
What is HTML Template Language (HTL)?
● Introduced with AEM 6.0
● Takes the place of JSP as the preferred server-side template system
for HTML
● Enforces separation of concerns between Presentation & Business
logic
● A HTL file contains HTML, some basic presentation logic and
variables to be evaluated at runtime
● Sightly was renamed to “HTML Template Language” from August
2016
www.tothenew.com
Why HTL?
● Simplified Development:
○ Purposely limited features: Easy to learn and enforces strict
separation of concerns between markup and logic.
○ HTL template is itself a valid HTML5 file: Doesn't break the validity of
the markup and keeps it readable
○ Allows HTML developers without Java knowledge and with little
product-specific knowledge to be able to edit HTL templates
○ Allows Java developers to focus on the back-end code without
worrying about HTML
After Sightly

Recommended for you

AEM - Client Libraries
AEM - Client LibrariesAEM - Client Libraries
AEM - Client Libraries

This document discusses client-side libraries in AEM and best practices for their use. It explains that clientlibs allow logical organization of JavaScript and CSS files and avoid duplicate includes. Key points covered include using cq:ClientLibraryFolders to define libraries, including them via cq:includeClientLib, dependencies vs embedding, debugging tools, themes, and minification. Best practices include placing component code in clientlibs, embedding to reduce requests, requesting from /etc, defining dependencies, and minification on publish.

jscq5aem
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

This document discusses using Sling Models with Sightly and JSP templates in AEM. It provides an overview of Sling Models, including their purpose, design goals, and key annotations. It also describes the standard injectors available in Sling Models and how to create custom injectors. The document outlines how to add Sling Model dependencies and use Sling Models within JSP and Sightly templates, including code examples. It concludes with a demonstration of Sling Models in action and information for appendix materials and questions.

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

This presentation cover Adobe AEM Dispatcher security and CDN and browser caching. This presentation is the second part of a webinar on AEM Dispatcher: http://dev.day.com/content/ddc/en/gems/dispatcher-caching---new-features-and-optimizations.html Visit url above to view the whole presentation. Domique Pfister the primary engineer developing AEM Dispatcher covers the first part on new features.

cq5aemadobe systems
www.tothenew.com
Why HTL?
● Increased Security:
○ HTL automatically filters and escapes all text being output to the
presentation layer to prevent cross-site-scripting(XSS) vulnerabilities.
○ Automatically applies the proper context-aware escaping to all
variables being output to the presentation layer
www.tothenew.com
AEM HTL Read–Eval–Print Loop
● To try out basic HTL, a live execution environment called the
Read Eval Print Loop can be used.
● Download Link & documentation:
https://github.com/Adobe-Marketing-Cloud/aem-htl-repl
● After package installation, go to /content/repl.html
?
www.tothenew.com
HTL Syntax
• Every HTL file is an HTML5 document or fragment, augmented with a
specific syntax that adds the dynamic functionality.
There are two different kind of Syntaxes:-
• HTL Block Statements:- To define structural block elements within HTL
file, HTL employs HTML5 data attributes. This allows to attach behavior
to existing HTML elements. Block statements can't be used inside html
comments, style n script elements. A block statement starts with data-
sly.
• HTL Expressions:- HTL expressions are delimited by characters ${ and }.
At runtime, these expressions are evaluated and their value is injected
into the outgoing HTML stream. Expressions can only be used in
attribute values, in element content, or in comments.
www.tothenew.com
Example
<h1 data-sly-test="${currentPage.title}">
<a href="${currentPage.path}.html">
${currentPage.title}
</a>
</h1>
• Output
<h1>
<a href="/content/my%20page.html">
My page title&#x21;
</a>
</h1>

Recommended for you

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

RichText Editor (RTE) is an integral component of AEM and it provides AEM authors a WYSIWYG text-editing experience on the web pages. RTE offers diverse configurations to developers. This presentation provides an in-depth understanding of this component and shows various concepts, use-cases, modes, configurations, best practices, limitations and troubleshooting that surround it. E-Seminar recording published here - https://helpx.adobe.com/experience-manager/kt/eseminars/gems/AEM-Rich-Text-Editor-RTE-Deep-Dive1.html

aemrterichtext editor
Integration patterns in AEM 6
Integration patterns in AEM 6Integration patterns in AEM 6
Integration patterns in AEM 6

This document discusses integration patterns in Adobe Experience Manager (AEM), including using Sling Models for dependency injection and accessing resources from different locations through a single ResourceResolver. It provides examples of integrating with backend APIs, databases, file systems and forms using techniques like ResourceProviders, Sling Filters and custom SlingServlets. It also covers accessing files from bundles and the filesystem using BundleResourceProvider and FsResourceProvider respectively.

aem6sling modelssling
Osgi
OsgiOsgi
Osgi

OSGI is a Java framework that implements a dynamic component model. It allows modular Java applications to be built from separate bundles that can be loaded, started, stopped and updated independently. Key aspects include: - Bundles are JAR files with additional configuration that can be loaded and stopped independently without affecting other bundles. - Services allow bundles to publish and discover capabilities via a registry. Dependencies between bundles are resolved dynamically. - The OSGi framework provides a lifecycle to manage the loading, starting and stopping of bundles. - Annotations like @Component, @Service and @Reference allow defining OSGi components and services using declarative services. - The OSGi specification is implemented by frameworks like

osgiosgi with aemosgi basics
www.tothenew.com
Useful Objects Available
• properties
• pageProperties
• Component
• currentDesign
• currentPage
• log
• out
• pageManager
• request
• resource
• response
• sling
• wcmmode
www.tothenew.com
Comments
HTL comments are HTML comments with additional syntax. They are
delimited like this:

However, the content of standard HTML comments, delimited like this:

will be passed through the HTL processor and expressions within the
comment will be evaluated.
www.tothenew.com
HTL Block Statements
● dat-sly-test
● data-sly-resource
● data-sly-include
● data-sly-attribute
● data-sly-element & data-sly-text
● data-sly-list
● data-sly-template & dat-sly-call
● data-sly-use
● data-sly-unwrap
www.tothenew.com
data-sly-test
• Conditionally removes the host element and it‘s content if an
expression evaluates to false.
• Values that can be converted to false are: undefined variables, null
values, the number zero, and empty strings.
• data-sly-test also supports the naming and reuse of tests.
Example
<div data-sly-test.author="${wcmmode.edit || wcmmode.design}">
Show this to the author
</div>
<div data-sly-test="${!author}">
Not in author mode anymore..
</div>

Recommended for you

Aem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricks

The document provides tips and best practices for configuring multiple farms in AEM Dispatcher. Key points include: - Splitting the Dispatcher configuration into multiple farms based on different caching needs, such as separate farms for DAM assets and pages. - Configuring different caching parameters and cache folders for each farm to optimize caching behavior. - Handling cache invalidation requests and vanity URLs across multiple farms. - Different approaches for flushing caches from Author and multiple Publishers to Dispatchers, and avoiding race conditions. - Bypassing the Dispatcher cache for select clients by rewriting URLs to include parameters checked by the Dispatcher configuration.

tipsconfigurationdispatcher
AEM Best Practices for Component Development
AEM Best Practices for Component DevelopmentAEM Best Practices for Component Development
AEM Best Practices for Component Development

This presentation describes how to easily get started with an efficient development workflow with Adobe Experience Manager 6.1. The tools and technologies presented are: * Project Archetype – https://github.com/Adobe-Marketing-Cloud/aem-project-archetype * AEM Eclipse Extension – https://docs.adobe.com/docs/en/dev-tools/aem-eclipse.html * AEM Brackets Extension – https://docs.adobe.com/docs/en/dev-tools/aem-brackets.html * Sightly Template Language – http://www.slideshare.net/GabrielWalt/component-development * Sightly REPL Tool – https://github.com/Adobe-Marketing-Cloud/aem-sightly-repl * Sightly TodoMVC Example – https://github.com/Adobe-Marketing-Cloud/aem-sightly-sample-todomvc

adobe experience managersampleweb design and development
Javascript 101
Javascript 101Javascript 101
Javascript 101

This document provides an introduction to JavaScript, covering basic concepts like data types, variables, operators, conditionals, loops, functions, arrays, and objects. It explains that JavaScript is an interpreted language that allows dynamic and interactive functionality on websites. Key points are demonstrated through examples, like using alert to output "Hello World" and basic math operations with variables.

javascripttutorial
www.tothenew.com
• data-sly-include : Includes the output of a rendering script run with the current
context, passing back control to the current Sightly script.
<div data-sly-include="template.html"></div>
<div data-sly-include="template.jsp"></div>
• The element on which a data-sly-include has been set is ignored and not
displayed
data-sly-include
www.tothenew.com
data-sly-resource
• Includes a rendered resource from the same server, using an absolute or relative path.
Examples:
<div data-sly-resource="${ @path='par',
resourceType='foundation/components/parsys'}"/>
With an expression more options can be specified:
<section data-sly-resource="${'my/path' @ appendPath='appended/path'}"></section>
<section data-sly-resource="${'my/path' @ prependPath='prepended/path'}"></section>
Manipulating selectors:
<section data-sly-resource="${'my/path' @ selectors='selector1.selector2'}" />
<section data-sly-resource="${'my/path' @ addSelectors=['selector1', 'selector2']}" />
<section data-sly-resource="${'my/path' @removeSelectors=['selector1','selector2']}" />
By default, the AEM decoration tags are disabled, the decorationTagName option allows to
bring them back, and the cssClassName to add classes to that element.
<article data-sly-resource="${'path/to/resource' @ decorationTagName='span',
cssClassName='className'}"></article>
www.tothenew.com
data-sly-attribute
• Sets an attribute or a group of attributes on the current element :
<tag class="className" data-sly-attribute.class="${myVar}"></tag>
This overwrites the content of the class attribute
Assuming that foobar = {'id' : 'foo', 'class' : 'bar'} ,
<input data-sly-attribute="${foobar}" type="text"/>
outputs : <input id="foo" class="bar" type="text"/>
• Attributes are processed left-to-right :
<div class="bar1" data-sly-attribute.class="bar2" data-sly-
attribute="${foobar}"></div>
outputs: <div id="foo" class="bar"></div>
www.tothenew.com
• Changes the element, mostly useful for setting element tags like h1..h6, th, td,
ol, ul :
<div data-sly-element"${'h1'}">Sightly Element Example</div>
outputs: <h1>Sightly Element Example</h1>
For security reasons, data-sly-element accepts only the following element names:
a abbr address article aside b bdi bdo blockquote br caption cite code col colgroup
data dd del dfn div dl dt em figcaption figure footer h1 h2 h3 h4 h5 h6 header i ins
kbd li main mark nav ol p pre q rp rt ruby s samp section small span strong sub
sup table tbody td tfoot th thead time tr u var wbr
data-sly-text
• Replaces the content of its host element with the specified text.
<p data-sly-text="${properties.jcr:description}">Lorem ipsum</p>
data-sly-element

Recommended for you

Hunting for security bugs in AEM webapps
Hunting for security bugs in AEM webappsHunting for security bugs in AEM webapps
Hunting for security bugs in AEM webapps

Presented on Hacktivity 2018 conference - https://www.hacktivity.com/bug-hunting-adobe-experience-manage.

aempentestinghacking
AEM GEMs Session Oak Lucene Indexes
AEM GEMs Session Oak Lucene IndexesAEM GEMs Session Oak Lucene Indexes
AEM GEMs Session Oak Lucene Indexes

Chetan Mehrotra, Senior Computer Scientist, and Alex Parvulescu, Senior Developer, Adobe presented on Jan 20, 2016. They describe the features of Oak Lucene indexes and how they can be used to get your queries perform better. In the second part we will talk about how asynchronous indexing works in general and how it can be monitored.To view the on-demand session go to: http://bit.ly/AEMGems1202016 or for the MP4 version http://bit.ly/AEMGemsMP41202016

oakaemapache sling
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction

Rasheed Amir presents on Spring Boot. He discusses how Spring Boot aims to help developers build production-grade Spring applications quickly with minimal configuration. It provides default functionality for tasks like embedding servers and externalizing configuration. Spring Boot favors convention over configuration and aims to get developers started quickly with a single focus. It also exposes auto-configuration for common Spring and related technologies so that applications can take advantage of them without needing to explicitly configure them.

spring bootjavaspring
www.tothenew.com
data-sly-list
● Repeats the content of the host element for each property in the provided
object.
<ul data-sly-list="${currentPage.listChildren}">
<li> index: ${itemList.index}, value: ${item.title} </li>
</ul>
<ul data-sly-list.child="${myObj}">
<li> key: ${child}, value: ${myObj[child]} </li>
</ul>
● itemList holds the following properties:
index: zero-based counter (0..length-1).
count: one-based counter (1..length).
first: true if the current item is the first item.
middle: true if the current item is neither the first nor the last item.
last: true if the current item is the last item.
odd: true if index is odd.
even: true if index is even.
www.tothenew.com
● Template blocks can be used like function calls:
○ Parameters can be passed when calling templates.
○ They also allow recursion.
● Template Declaration :
<template data-sly-template.example="${@ class, text}">
<span class="${class}">${text}</span>
</template>
● Call Statement :
<div data-sly-call="${example @ class=‘css-class', text='Hi'}"></div>
● Output:
<div><span class="css-class">Hi</span></div>
Template & Call Statements
www.tothenew.com
• Initializes a helper object (defined in JavaScript or Java) and exposes it through a
variable:
JS: <div data-sly-use.page="customPage.js">${page.foo}</div>
Java: <div data-sly-use.nav="Navigation">${nav.foo}</div>
• Parameters can be passed to the Use-API by using expression options:
<div data-sly-use.nav="${'Navigation' @ depth=1,showVisible=!wcmmode.edit}">
${nav.foo}
</div>
• Also used to load data-sly-template markup snippets located in a different file :
data-sly-use

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

<div data-sly-use.library="library.html"
data-sly-call="${library.foo @
text='Hi'}"> </div>
Output:
<div><span class="example">Hi</span></div>
www.tothenew.com
HTL Use-API
Java Use-API JavaScript Use-API
Pros ● faster
● can be inspected with a
debugger
● easy to unit-test
● can be modified by front-end
developers
● is located within the component,
keeping the view logic of a
component close to its
corresponding template

Recommended for you

Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript

This document provides an introduction to JavaScript and its uses for web programming. It explains that JavaScript is a client-side scripting language that allows web pages to become interactive. Some key points covered include: - JavaScript can change HTML content, styles, validate data, and make calculations. - Functions are blocks of code that perform tasks when invoked by events or called in code. - Events like clicks or keyboard presses trigger JavaScript code. - The DOM (Document Object Model) represents an HTML document that JavaScript can access and modify. - Forms and user input can be accessed and processed using the DOM. - Programming flow can be controlled with conditional and loop statements. -

javascriptintroduction
Sharing Data Between Angular Components
Sharing Data Between Angular ComponentsSharing Data Between Angular Components
Sharing Data Between Angular Components

The document discusses various methods for sharing data between Angular components, including: 1) Parent to child components using @Input to pass data via templates. 2) Child to parent using @ViewChild and AfterViewInit lifecycle hook to access child component properties. 3) Child to parent using @Output and event emitters to emit data on user events like button clicks. 4) Between unrelated components using a shared service with RxJs Subjects to share stream of data between all components accessing the service.

angularbasic concepts of angularsharing data between components
A story of the passive aggressive sysadmin of AEM
A story of the passive aggressive sysadmin of AEMA story of the passive aggressive sysadmin of AEM
A story of the passive aggressive sysadmin of AEM

# By Frans Rosén Adobe Experience Manager is an enterprise CMS with a troubled history. It was created with the angle of high customization factor, enabling consulting firms to deploy it all over the world for huge customers. Then came security. Frans will go through some terrible default configuration mistakes, Adobe’s love for bad Flash and how a sysadmin accidentialy exposed an international multi billion dollar company using only sad thoughts. # About speaker Frans Rosén is a tech entrepreneur, bug bounty hunter and a Security Advisor at Detectify, a security service for developers. He’s a frequent blogger at Detectify Labs and a top ranked participant of bug bounty programs, receiving some of the highest bounty payouts ever on HackerOne. Frans was recently featured as #2 on Hackread’s list of 10 Famous Bug Bounty Hunters of All Time and the results of his security research has been covered in numerous international publications such as Observer, BBC, Ars Technica, Wired and Mashable.

securitybugbountyaem
www.tothenew.com
Java Use-API enables a HTL file to access helper methods in a custom Java class.
1. Implementing Use interface:
public class HTLComponent implements Use {
@Override
public void init(Bindings bindings) {
Resource resource = (Resource)bindings.get("resource");
ValueMap properties = (ValueMap)bindings.get("properties");
// Parameters passed to the use-class
String param1 = (String) bindings.get("param1");
}
In AEM 6.2, io.sightly.java.api.Use is deprecated,
org.apache.sling.scripting.sightly.pojo.Use is used instead.
Java Use-API
www.tothenew.com
Java Use-API
2. Extend WCMUsePojo class:
public class HTLComponent extends WCMUsePojo {
private String myTitle;
@Override
public void activate() {
String text = get("text", String.class);
myTitle = "My Project " + text + getCurrentPage().getTitle()
+ “ : ” + getProperties().get("title", "");
}
public String getMyTitle() { return myTitle; }
}
In AEM 6.2, WCMUse is deprecated, com.adobe.cq.sightly.WCMUsePojo used
instead.
www.tothenew.com
• If the Java source file is in the same folder as the HTL file
<div data-sly-use.nav="Navigation">${nav.foo}</div>
Otherwise,
<div data-sly-use.nav="com.htl.model.Navigation">${nav.foo}</div>
• HTL Use-API resolution
Find a Java UseClass in the same directory OR with a fully qualified class name
Try to adapt the current Resource/Request to UseClass, if unsuccessful, try to
instantiate UseClass with a zero-argument constructor.
Within HTL, bind the newly adapted or created object to the localName.
If UseClass implements the Use interface then call the init method, passing the
current execution context (a javax.scripting.Bindings object).
UseClass extending WCMUse is a special case of implementing Use providing the
convenience context methods and its activate method is automatically called
from Use.init.
If UseClass is a path to a HTL file containing a data-sly-template, prepare the
template.
Otherwise, if UseClass is a path to a JavaScript use-class, prepare the use-class.
data-sly-use (cont.)
www.tothenew.com
• Enables a HTL file to access helper code written in JavaScript.
• Allows all complex business logic to be encapsulated in the JavaScript code, while the HTL
code deals only with direct markup production.
use(function () {
var Constants = {
DESCRIPTION_PROP: "jcr:description",
DESCRIPTION_LENGTH: 50
};
var title = currentPage.getNavigationTitle() || currentPage.getTitle() ||
currentPage.getName();
var description = properties.get(Constants.DESCRIPTION_PROP, "").substr(0,
Constants.DESCRIPTION_LENGTH);
return {
title: title,
description: description
};
});
data-sly-use JavaScript Use Api

Recommended for you

jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners

Slides for presentation C002 | jQuery for beginners in Sumofyou Technologies

javascriptjquery
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding

This document discusses data binding in AngularJS. It explains what data binding is, the difference between one-time and two-way binding, and how data binding works through dirty checking. Data binding connects the UI and business logic by allowing changes in the model to be reflected in the view and vice versa. One-time binding only updates the view once from the controller value, reducing the number of watchers and improving performance compared to two-way binding. The document also provides examples of data binding and takes questions.

CIRCUIT 2015 - UI Customization in AEM 6.1
CIRCUIT 2015 - UI Customization in AEM 6.1CIRCUIT 2015 - UI Customization in AEM 6.1
CIRCUIT 2015 - UI Customization in AEM 6.1

Andreea Corbeanu & Christian Meyer - Adobe How to extend a dialog by purely providing the missing pieces via the Sling Resource Merger * Customizable search facets How to create custom search facets * Custom page properties bulk editing How to add a custom field to the bulk editing

user interfaceaemui
www.tothenew.com
Client libraries helper template library
The client libraries helper template library
(/libs/granite/HTL/templates/clientlib.html) can be loaded
through data-sly-use and stored in a clientLib block element variable.
Loading the library's CSS style sheets and JavaScript is done
through data-sly-call. The clientLib template library exposes three
templates:
• css - loads only the CSS files of the referenced client libraries
• js - loads only the JavaScript files of the referenced client libraries
• all - loads all the files of the referenced client libraries
www.tothenew.com
Client libraries helper template library Example
<head data-sly-
use.clientLib="${'/libs/granite/HTL/templates/clientlib.html'}">
<css data-sly-call="${clientLib.css @ categories=['category1',
'category2']}" data-sly-unwrap/>
</head>
<body>

<js data-sly-call="${clientLib.js @ categories=['category1',
'category2']}" data-sly-unwrap/>
</body>
www.tothenew.com
• The <sly> HTML tag can be used to remove the current element, allowing only
its children to be displayed:
<sly data-sly-test="${event.hasDate}" >
<span>Hello</span>
</sly>
• Its functionality is similar to the data-sly-unwrap block element :
<div data-sly-test="${event.hasDate}" data-sly-unwrap>
<span>Hello</span>
</div>
Both Output :
<span>Hello</span>
• Although not a valid HTML 5 tag, the <sly> tag can be displayed in the final
output using data-sly-unwrap:
<sly data-sly-unwrap="${false}"></sly>
outputs: <sly></sly>
<sly> & data-sly-unwrap
www.tothenew.com
Expression Options

Recommended for you

Audit of site usability, SEO
Audit of site usability, SEOAudit of site usability, SEO
Audit of site usability, SEO

This audit of a law firm's website www.awf.ae identifies several issues that need to be addressed to improve usability and marketing. It is unclear what services the site offers or how visitors' problems could be resolved. The navigation is unclear and there is too much unreadable text. Key recommendations include simplifying content, adding things like phone numbers and opening hours, improving speed and the mobile version, restructuring articles to drive sales, and analyzing SEO and traffic sources to improve marketing. Addressing these issues would help visitors understand what the site offers and how it can help solve their legal issues.

auditseoweb analytics
Sales Process
Sales Process Sales Process
Sales Process

The document outlines steps to improve a sales process, including defining strengths and weaknesses, breaking improvements into chunks, coaching for better performance, focusing on outcomes, building credibility and rapport with customers, listening to understand their needs, gaining permission to provide solutions, offering experiences over words, role playing deals to practice asking for outcomes, removing emotions when handling objections, planning next steps before meetings, and developing lists to support the process. Implementing a defined sales process will enable salespeople to improve performance.

sales targets
SEO - Estrategias de Posicionamiento en Buscadores
SEO - Estrategias de Posicionamiento en BuscadoresSEO - Estrategias de Posicionamiento en Buscadores
SEO - Estrategias de Posicionamiento en Buscadores

Este documento describe las técnicas de SEO (Search Engine Optimization) o posicionamiento en buscadores. Explica el análisis de palabras clave, incluyendo la definición, estudio de la competencia y selección de palabras clave. También cubre las técnicas SEO "on-page", como elementos como el título, la descripción y los enlaces internos. Por último, resume las técnicas SEO "off-page" como el link building y la creación de enlaces externos desde otras páginas para mejorar la visibilidad de un sit

seo off pageseo on pageseo services
www.tothenew.com
Display Context Option
The context option offers control over escaping and XSS protection.
• Allowing some HTML markup (filtering out scripts)
<div>${‘<p>Hello</p>’ @ context='html'}</div>
Without context :
&lt;p&gt;hello&lt;/p&gt;
• Adding URI validation protection
<p data-link="${link @ context='uri'}">text</p>
• Applying CSS string escaping
<style> a { font-family: "${myFont @ context='styleString'}"; } </style>
www.tothenew.com
Display Context Option
Context Use
• html
• text
• elementName
• uri
• scriptString
• scriptComment
• scriptRegExp
• styleString
• styleComment
• comment
• number
• unsafe
Outputs HTML - Removes markup that may contain XSS risks
For simple HTML content - Encodes all HTML
Allows only element names that are white-listed, else outputs 'div'
To get valid Href link or path
Applies JavaScript string escaping
For JavaScript block comments
To apply JavaScript regular expression escaping
To apply CSS string escaping
For CSS comments
To apply HTML comment escaping
Outputs zero if the value is not a number
Disables XSS protection completely, use this at your own risk.
www.tothenew.com
String Format Option
Numbered parameters can be used for injecting variables:
${'Assets {0}' @ format=properties.assetName}
OR
${'Assets {0}' @ format=[properties.assetName]}
${'Page {0} of {1}' @ format=[current, total]}
Array Join Option
The join option allows to control the output of an ahorray object by specifying the
separator string. This can for e.g. be useful for setting class-names
${['one', 'two'] @ join='; '} 
<span class="${myListOfClassNames @ join=' '}"></span>
www.tothenew.com
Internationalization (@i18n)
To translate a string to the resource language:
${'Assets' @ i18n}
Two more options can be used with i18n:
• locale : Overrides the language from the source. For e.g.: en-US or fr-CH
• hint : Allows to provide some information about the context for the translators.
${'Assets' @ i18n, locale='en-US', hint='Translation Hint'}

Recommended for you

Identitas Nasional
Identitas NasionalIdentitas Nasional
Identitas Nasional

Kelompok IV: Malik Ibrahim Muhammad Ilham Akbar Mutiara Dhien Aulia Okta Widiastuti Rizki Perdana Wira Utama Syaiddatur Rahmawati Wira Putera Guna

pendidikan kewarganegaraan
web shop company
web shop companyweb shop company
web shop company

WSC is a small IT company in Estonia and Latvia that provides web development solutions. It has three directors leading employees across marketing, technical, and other areas. WSC aims to deliver high-tech solutions quickly using its ABC methodology. It plans to move from services to products by completing its MCCNSE project and targeting the Baltic market. WSC believes in innovation and its upcoming MCCNSE product could succeed in the market.

KoprowskiT-Difinify2017-SQL_ServerBackup_In_The_Cloud
KoprowskiT-Difinify2017-SQL_ServerBackup_In_The_CloudKoprowskiT-Difinify2017-SQL_ServerBackup_In_The_Cloud
KoprowskiT-Difinify2017-SQL_ServerBackup_In_The_Cloud

Backup? Who cares! Now and Then? We store our data in the cloud. Somewhere in the Cloud. Which Cloud? Who cares! But we are still SQL Server Professionals, so… are we need backup? Should we use newest opportunities or old methods? Are we going a step further or step back? On my session, I will try to find answers for all of those (and more) questions. Demos, cases, and examples from the world of backup. And of course worst practices.

backupnew zealanddba
www.tothenew.com
URI Manipulation
• Scheme - Allows adding or removing the scheme part for a URI :
${'example.com/path/page.html' @ scheme='http'}
outputs: http://example.com/path/page.html
${'http://example.com/path/page.html' @ scheme='https'}
outputs: https://example.com/path/page.html
• Domain - Allows adding or replacing the host and port (domain) part for a URI :
${'///path/page.html' @ domain='example.org'}
outputs: //example.org/path/page.html
${'http://www.example.com/path/page.html' @ domain='www.example.org'}
outputs: http://www.example.org/path/page.html
www.tothenew.com
URI Manipulation
Path / prependPath / appendPath – Modify the path that identifies a resource :
${'http://example.com/this/one.selector.html/suffix?key=value’@ path='that/two'}
outputs: http://example.com/that/two.selector.html/suffix?key=value#
${'http://example.com/this/one.selector.html/suffix?key=value' @ path=‘’}
outputs: http://example.com/this/one.selector.html/suffix?key=value
${'path' @ prependPath='..'}
outputs: ../path
${'http://example.com/path/page.html' @ prependPath='foo'}
outputs: http://example.com/foo/path/page.html
${'one' @ appendPath='two'}
outputs: one/two
www.tothenew.com
URI Manipulation
Selectors / addSelectors / removeSelectors - Modifies or removes the selectors
from a URI:
${'path/page.woo.foo.html' @ selectors='foo.bar'}
outputs: path/page.foo.bar.html
${'path/page.woo.foo.html' @ selectors=['foo', 'bar']}
outputs: path/page.foo.bar.html
${'path/page.woo.foo.html' @ addSelectors='foo.bar'}
outputs: path/page.woo.foo.bar.html
${'path/page.woo.foo.html' @ removeSelectors=['foo', 'bar']}
outputs: path/page.woo.html
www.tothenew.com
URI Manipulation
query / addQuery / removeQuery- adds, replaces or removes the query segment of a URI,
depending on the contents of its map value :
assuming that jsuse.query evaluates to:
{
"query": {
"q" : "sightly",
"array" : [1, 2, 3]
}
}
${'http://www.example.org/search' @ query=jsuse.query}
outputs:
http://www.example.org/search?q=sightly&amp;array=1&amp;array=2&amp;array=3
${'http://www.example.org/search?s=1' @ addQuery=jsuse.query}
outputs:
http://www.example.org/search?s=1&amp;q=sightly&amp;array=1&amp;array=2&amp;arra
y=3
${'http://www.example.org/search?s=1&q=sightly' @ removeQuery=['s', 'q']}
outputs: http://www.example.org/search

Recommended for you

Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js

HTML is a markup language used to define the structure and layout of web pages. CSS is used to style and lay out HTML elements, and JavaScript can be used to program behaviors and interactions in web pages. jQuery is a JavaScript library that simplifies HTML document traversal and manipulation, as well as event handling, animations, and Ajax interactions for rapid web development.

Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation

about this presentation: 1) this presentation was a quickie for non-tech employees, who wanted a basic understanding of html/css, as it related to a white-label SAAS product; 2) the back-end/front-end definitions relate to the specific application (it's inaccurate if node.js is in the picture)

Html Workshop
Html WorkshopHtml Workshop
Html Workshop

HTML is a markup language used to define the structure and layout of web pages. HTML uses tags to mark elements like headings, paragraphs, links, images, and tables. Some key tags include: <h1> for main headings, <p> for paragraphs, <a> for links, <img> for images, and <table> for tables. Elements are everything between a starting and ending tag. HTML documents contain tags and plain text and are displayed in web browsers.

www.tothenew.com
URI Manipulation
• Extension - adds, modifies or removes the extension from a URI:
${'path/page.json?key=value' @ extension='html'}
outputs: path/page.html?key=value
${'path/page.json#fragment' @ extension='html'}
outputs: path/page.html#fragment
• fragment - adds, modifies or replaces the fragment segment of a URI :
${'path/page' @ fragment='fragment'}
outputs: path/page#fragment
${'path/page#one' @ fragment='two'}
outputs: path/page#two
${'path/page#one' @ fragment}
outputs: path/page
www.tothenew.com
Best practices
● Abuse of sly
● HTL comments instead of Html comments
● Reuse code using templates
● Use api to be used only when the HTL file alone is not enough to
implement logic
● Javascript use is slower than Java use class so use Javascript only for
less intensive logic
● Use local java use class if the class is used only for that component,
otherwise create a bundle use class
● Passing a parameter to a use-class should only be done when the use-
class is used in a data-sly-template file which itself is called from another
HTL file with parameters that need to be passed on.
www.tothenew.com
Moving from JSP to HTL
• Components written in HTL are compatible with components
written in JSP or ESP.
A JSP can include a HTL file like this,
• <cq:include script="footer.html"/>
and a HTL file can include a JSP like this,
<div data-sly-include="footer.jsp"></div>
www.tothenew.com
• HTL Specification :
https://docs.adobe.com/docs/en/htl/overview.html
https://github.com/Adobe-Marketing-Cloud/sightly-
spec/blob/master/SPECIFICATION.md#31-sly
• Gabriel Walt’s Slideshare PPT:
http://www.slideshare.net/GabrielWalt/component-development
• http://www.netcentric.biz/blog/2015/08/aem-sightly-style-guide.html
• http://www.citytechinc.com/content/dam/circuit/Component%20Development.pd
f
• http://stackoverflow.com/questions/27583326/expression-option-sightly
References

Recommended for you

Kick start @ html5
Kick start @ html5Kick start @ html5
Kick start @ html5

The document provides an overview of HTML5, describing it as the latest and most enhanced version of HTML. It outlines several new features of HTML5, including new semantic elements, forms improvements, local storage, web sockets, canvas, audio/video embedding, geolocation, and drag and drop. It also covers HTML5 syntax rules and compatibility with older browsers. The document is intended to provide information on HTML5's easy learning and use for rapid web development.

html5htmlmozilla firefox
Html 5, a gentle introduction
Html 5, a gentle introductionHtml 5, a gentle introduction
Html 5, a gentle introduction

A gentle introduction to the tag soup that HTML 5 brings us and how to transition to it. The new, the good and the deprecated.

htmlhtml 5web development
Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)

This document provides an introduction to HTML, CSS, and WordPress. It covers the basics of HTML including common tags for formatting text, images, and links. It then discusses using CSS to style HTML elements using classes, IDs, and other selectors. Finally, it gives an overview of how HTML and CSS are used together in WordPress templates and themes.

htmlwordpresscss
www.tothenew.com

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
 
slingmodels
slingmodelsslingmodels
slingmodels
Ankur Chauhan
 
AEM - Client Libraries
AEM - Client LibrariesAEM - Client Libraries
AEM - Client Libraries
Prabhdeep Singh
 
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 HUB
 
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
Andrew Khoury
 
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
Hanish Bansal
 
Integration patterns in AEM 6
Integration patterns in AEM 6Integration patterns in AEM 6
Integration patterns in AEM 6
Yuval Ararat
 
Osgi
OsgiOsgi
Aem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricks
Ashokkumar T A
 
AEM Best Practices for Component Development
AEM Best Practices for Component DevelopmentAEM Best Practices for Component Development
AEM Best Practices for Component Development
Gabriel Walt
 
Javascript 101
Javascript 101Javascript 101
Javascript 101
Shlomi Komemi
 
Hunting for security bugs in AEM webapps
Hunting for security bugs in AEM webappsHunting for security bugs in AEM webapps
Hunting for security bugs in AEM webapps
Mikhail Egorov
 
AEM GEMs Session Oak Lucene Indexes
AEM GEMs Session Oak Lucene IndexesAEM GEMs Session Oak Lucene Indexes
AEM GEMs Session Oak Lucene Indexes
AdobeMarketingCloud
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
Rasheed Waraich
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
Sharing Data Between Angular Components
Sharing Data Between Angular ComponentsSharing Data Between Angular Components
Sharing Data Between Angular Components
Squash Apps Pvt Ltd
 
A story of the passive aggressive sysadmin of AEM
A story of the passive aggressive sysadmin of AEMA story of the passive aggressive sysadmin of AEM
A story of the passive aggressive sysadmin of AEM
Frans Rosén
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
Arulmurugan Rajaraman
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
Duy Khanh
 

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?
 
slingmodels
slingmodelsslingmodels
slingmodels
 
AEM - Client Libraries
AEM - Client LibrariesAEM - Client Libraries
AEM - Client Libraries
 
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
 
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
 
Integration patterns in AEM 6
Integration patterns in AEM 6Integration patterns in AEM 6
Integration patterns in AEM 6
 
Osgi
OsgiOsgi
Osgi
 
Aem dispatcher – tips & tricks
Aem dispatcher – tips & tricksAem dispatcher – tips & tricks
Aem dispatcher – tips & tricks
 
AEM Best Practices for Component Development
AEM Best Practices for Component DevelopmentAEM Best Practices for Component Development
AEM Best Practices for Component Development
 
Javascript 101
Javascript 101Javascript 101
Javascript 101
 
Hunting for security bugs in AEM webapps
Hunting for security bugs in AEM webappsHunting for security bugs in AEM webapps
Hunting for security bugs in AEM webapps
 
AEM GEMs Session Oak Lucene Indexes
AEM GEMs Session Oak Lucene IndexesAEM GEMs Session Oak Lucene Indexes
AEM GEMs Session Oak Lucene Indexes
 
Spring boot introduction
Spring boot introductionSpring boot introduction
Spring boot introduction
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
Sharing Data Between Angular Components
Sharing Data Between Angular ComponentsSharing Data Between Angular Components
Sharing Data Between Angular Components
 
A story of the passive aggressive sysadmin of AEM
A story of the passive aggressive sysadmin of AEMA story of the passive aggressive sysadmin of AEM
A story of the passive aggressive sysadmin of AEM
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
 

Viewers also liked

CIRCUIT 2015 - UI Customization in AEM 6.1
CIRCUIT 2015 - UI Customization in AEM 6.1CIRCUIT 2015 - UI Customization in AEM 6.1
CIRCUIT 2015 - UI Customization in AEM 6.1
ICF CIRCUIT
 
Audit of site usability, SEO
Audit of site usability, SEOAudit of site usability, SEO
Audit of site usability, SEO
Alex Dmitriev
 
Sales Process
Sales Process Sales Process
SEO - Estrategias de Posicionamiento en Buscadores
SEO - Estrategias de Posicionamiento en BuscadoresSEO - Estrategias de Posicionamiento en Buscadores
SEO - Estrategias de Posicionamiento en Buscadores
Mercedes Fuster Sanz
 
Identitas Nasional
Identitas NasionalIdentitas Nasional
Identitas Nasional
Pahmi Agustian
 
web shop company
web shop companyweb shop company
web shop company
sainath balasani
 
KoprowskiT-Difinify2017-SQL_ServerBackup_In_The_Cloud
KoprowskiT-Difinify2017-SQL_ServerBackup_In_The_CloudKoprowskiT-Difinify2017-SQL_ServerBackup_In_The_Cloud
KoprowskiT-Difinify2017-SQL_ServerBackup_In_The_Cloud
Tobias Koprowski
 

Viewers also liked (7)

CIRCUIT 2015 - UI Customization in AEM 6.1
CIRCUIT 2015 - UI Customization in AEM 6.1CIRCUIT 2015 - UI Customization in AEM 6.1
CIRCUIT 2015 - UI Customization in AEM 6.1
 
Audit of site usability, SEO
Audit of site usability, SEOAudit of site usability, SEO
Audit of site usability, SEO
 
Sales Process
Sales Process Sales Process
Sales Process
 
SEO - Estrategias de Posicionamiento en Buscadores
SEO - Estrategias de Posicionamiento en BuscadoresSEO - Estrategias de Posicionamiento en Buscadores
SEO - Estrategias de Posicionamiento en Buscadores
 
Identitas Nasional
Identitas NasionalIdentitas Nasional
Identitas Nasional
 
web shop company
web shop companyweb shop company
web shop company
 
KoprowskiT-Difinify2017-SQL_ServerBackup_In_The_Cloud
KoprowskiT-Difinify2017-SQL_ServerBackup_In_The_CloudKoprowskiT-Difinify2017-SQL_ServerBackup_In_The_Cloud
KoprowskiT-Difinify2017-SQL_ServerBackup_In_The_Cloud
 

Similar to HTL(Sightly) - All you need to know

Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
Knoldus Inc.
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
Shawn Calvert
 
Html Workshop
Html WorkshopHtml Workshop
Html Workshop
vardanyan99
 
Kick start @ html5
Kick start @ html5Kick start @ html5
Kick start @ html5
Umesh Agarwal
 
Html 5, a gentle introduction
Html 5, a gentle introductionHtml 5, a gentle introduction
Html 5, a gentle introduction
Diego Scataglini
 
Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)
Christopher Ross
 
SDP_-_Module_4.ppt
SDP_-_Module_4.pptSDP_-_Module_4.ppt
SDP_-_Module_4.ppt
ssuser568d77
 
HTML Foundations, part 1
HTML Foundations, part 1HTML Foundations, part 1
HTML Foundations, part 1
Shawn Calvert
 
Html and html5 cheat sheets
Html and html5 cheat sheetsHtml and html5 cheat sheets
Html and html5 cheat sheets
Zafer Galip Ozberk
 
HTML - hypertext markup language
HTML - hypertext markup languageHTML - hypertext markup language
HTML - hypertext markup language
Basmaa Mostafa
 
Lecture 2 HTML part 1.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 2 HTML part 1.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 2 HTML part 1.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 2 HTML part 1.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
ZahouAmel1
 
Html5, a gentle introduction
Html5, a gentle introduction Html5, a gentle introduction
Html5, a gentle introduction
Diego Scataglini
 
PHP HTML CSS Notes
PHP HTML CSS  NotesPHP HTML CSS  Notes
PHP HTML CSS Notes
Tushar Rajput
 
Session ii(html)
Session ii(html)Session ii(html)
Session ii(html)
Shrijan Tiwari
 
Discovering Django - zekeLabs
Discovering Django - zekeLabsDiscovering Django - zekeLabs
Discovering Django - zekeLabs
zekeLabs Technologies
 
Introduction to Html5, css, Javascript and Jquery
Introduction to Html5, css, Javascript and JqueryIntroduction to Html5, css, Javascript and Jquery
Introduction to Html5, css, Javascript and Jquery
valuebound
 
Dhtml chapter2
Dhtml chapter2Dhtml chapter2
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
fishwarter
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
fishwarter
 
Web technology
Web technologyWeb technology
Web technology
Partnered Health
 

Similar to HTL(Sightly) - All you need to know (20)

Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
 
Html Workshop
Html WorkshopHtml Workshop
Html Workshop
 
Kick start @ html5
Kick start @ html5Kick start @ html5
Kick start @ html5
 
Html 5, a gentle introduction
Html 5, a gentle introductionHtml 5, a gentle introduction
Html 5, a gentle introduction
 
Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)Building the basics (WordPress Ottawa 2014)
Building the basics (WordPress Ottawa 2014)
 
SDP_-_Module_4.ppt
SDP_-_Module_4.pptSDP_-_Module_4.ppt
SDP_-_Module_4.ppt
 
HTML Foundations, part 1
HTML Foundations, part 1HTML Foundations, part 1
HTML Foundations, part 1
 
Html and html5 cheat sheets
Html and html5 cheat sheetsHtml and html5 cheat sheets
Html and html5 cheat sheets
 
HTML - hypertext markup language
HTML - hypertext markup languageHTML - hypertext markup language
HTML - hypertext markup language
 
Lecture 2 HTML part 1.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 2 HTML part 1.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 2 HTML part 1.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 2 HTML part 1.pptxLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
 
Html5, a gentle introduction
Html5, a gentle introduction Html5, a gentle introduction
Html5, a gentle introduction
 
PHP HTML CSS Notes
PHP HTML CSS  NotesPHP HTML CSS  Notes
PHP HTML CSS Notes
 
Session ii(html)
Session ii(html)Session ii(html)
Session ii(html)
 
Discovering Django - zekeLabs
Discovering Django - zekeLabsDiscovering Django - zekeLabs
Discovering Django - zekeLabs
 
Introduction to Html5, css, Javascript and Jquery
Introduction to Html5, css, Javascript and JqueryIntroduction to Html5, css, Javascript and Jquery
Introduction to Html5, css, Javascript and Jquery
 
Dhtml chapter2
Dhtml chapter2Dhtml chapter2
Dhtml chapter2
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
The Django Web Application Framework 2
The Django Web Application Framework 2The Django Web Application Framework 2
The Django Web Application Framework 2
 
Web technology
Web technologyWeb technology
Web technology
 

Recently uploaded

Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …
908dutch
 
MVP Mobile Application - Codearrest.pptx
MVP Mobile Application - Codearrest.pptxMVP Mobile Application - Codearrest.pptx
MVP Mobile Application - Codearrest.pptx
Mitchell Marsh
 
React Native vs Flutter - SSTech System
React Native vs Flutter  - SSTech SystemReact Native vs Flutter  - SSTech System
React Native vs Flutter - SSTech System
SSTech System
 
Leading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptxLeading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptx
taskroupseo
 
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsSeamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Estuary Flow
 
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) AWS Security .pdf
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) AWS Security .pdfAWS Cloud Practitioner Essentials (Second Edition) (Arabic) AWS Security .pdf
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) AWS Security .pdf
karim wahed
 
What is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for FreeWhat is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for Free
TwisterTools
 
introduction of Ansys software and basic and advance knowledge of modelling s...
introduction of Ansys software and basic and advance knowledge of modelling s...introduction of Ansys software and basic and advance knowledge of modelling s...
introduction of Ansys software and basic and advance knowledge of modelling s...
sachin chaurasia
 
ThaiPy meetup - Indexes and Django
ThaiPy meetup - Indexes and DjangoThaiPy meetup - Indexes and Django
ThaiPy meetup - Indexes and Django
akshesh doshi
 
React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...
React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...
React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...
Semiosis Software Private Limited
 
Top 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your WebsiteTop 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your Website
e-Definers Technology
 
dachnug51 - Whats new in domino 14 .pdf
dachnug51 - Whats new in domino 14  .pdfdachnug51 - Whats new in domino 14  .pdf
dachnug51 - Whats new in domino 14 .pdf
DNUG e.V.
 
Development of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML TechnologiesDevelopment of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML Technologies
MaisnamLuwangPibarel
 
A Comparative Analysis of Functional and Non-Functional Testing.pdf
A Comparative Analysis of Functional and Non-Functional Testing.pdfA Comparative Analysis of Functional and Non-Functional Testing.pdf
A Comparative Analysis of Functional and Non-Functional Testing.pdf
kalichargn70th171
 
WEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service ProvidersWEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service Providers
Severalnines
 
Intro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AIIntro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AI
Ortus Solutions, Corp
 
ENISA Threat Landscape 2023 documentation
ENISA Threat Landscape 2023 documentationENISA Threat Landscape 2023 documentation
ENISA Threat Landscape 2023 documentation
sofiafernandezon
 
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
Migrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS CloudMigrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS Cloud
Ortus Solutions, Corp
 
ANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdfANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdf
sachin chaurasia
 

Recently uploaded (20)

Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …Prada Group Reports Strong Growth in First Quarter …
Prada Group Reports Strong Growth in First Quarter …
 
MVP Mobile Application - Codearrest.pptx
MVP Mobile Application - Codearrest.pptxMVP Mobile Application - Codearrest.pptx
MVP Mobile Application - Codearrest.pptx
 
React Native vs Flutter - SSTech System
React Native vs Flutter  - SSTech SystemReact Native vs Flutter  - SSTech System
React Native vs Flutter - SSTech System
 
Leading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptxLeading Project Management Tool Taskruop.pptx
Leading Project Management Tool Taskruop.pptx
 
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple StepsSeamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
Seamless PostgreSQL to Snowflake Data Transfer in 8 Simple Steps
 
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) AWS Security .pdf
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) AWS Security .pdfAWS Cloud Practitioner Essentials (Second Edition) (Arabic) AWS Security .pdf
AWS Cloud Practitioner Essentials (Second Edition) (Arabic) AWS Security .pdf
 
What is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for FreeWhat is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for Free
 
introduction of Ansys software and basic and advance knowledge of modelling s...
introduction of Ansys software and basic and advance knowledge of modelling s...introduction of Ansys software and basic and advance knowledge of modelling s...
introduction of Ansys software and basic and advance knowledge of modelling s...
 
ThaiPy meetup - Indexes and Django
ThaiPy meetup - Indexes and DjangoThaiPy meetup - Indexes and Django
ThaiPy meetup - Indexes and Django
 
React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...
React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...
React vs Next js: Which is Better for Web Development? - Semiosis Software Pr...
 
Top 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your WebsiteTop 10 Tips To Get Google AdSense For Your Website
Top 10 Tips To Get Google AdSense For Your Website
 
dachnug51 - Whats new in domino 14 .pdf
dachnug51 - Whats new in domino 14  .pdfdachnug51 - Whats new in domino 14  .pdf
dachnug51 - Whats new in domino 14 .pdf
 
Development of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML TechnologiesDevelopment of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML Technologies
 
A Comparative Analysis of Functional and Non-Functional Testing.pdf
A Comparative Analysis of Functional and Non-Functional Testing.pdfA Comparative Analysis of Functional and Non-Functional Testing.pdf
A Comparative Analysis of Functional and Non-Functional Testing.pdf
 
WEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service ProvidersWEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service Providers
 
Intro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AIIntro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AI
 
ENISA Threat Landscape 2023 documentation
ENISA Threat Landscape 2023 documentationENISA Threat Landscape 2023 documentation
ENISA Threat Landscape 2023 documentation
 
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
 
Migrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS CloudMigrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS Cloud
 
ANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdfANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdf
 

HTL(Sightly) - All you need to know

  • 2. www.tothenew.com Agenda ● What is HTL? ● Why HTL? ● Global Objects ● HTL Block Statements ● HTL Use-API ● HTL Expression Options ● Best Practises
  • 3. www.tothenew.com What is HTML Template Language (HTL)? ● Introduced with AEM 6.0 ● Takes the place of JSP as the preferred server-side template system for HTML ● Enforces separation of concerns between Presentation & Business logic ● A HTL file contains HTML, some basic presentation logic and variables to be evaluated at runtime ● Sightly was renamed to “HTML Template Language” from August 2016
  • 4. www.tothenew.com Why HTL? ● Simplified Development: ○ Purposely limited features: Easy to learn and enforces strict separation of concerns between markup and logic. ○ HTL template is itself a valid HTML5 file: Doesn't break the validity of the markup and keeps it readable ○ Allows HTML developers without Java knowledge and with little product-specific knowledge to be able to edit HTL templates ○ Allows Java developers to focus on the back-end code without worrying about HTML After Sightly
  • 5. www.tothenew.com Why HTL? ● Increased Security: ○ HTL automatically filters and escapes all text being output to the presentation layer to prevent cross-site-scripting(XSS) vulnerabilities. ○ Automatically applies the proper context-aware escaping to all variables being output to the presentation layer
  • 6. www.tothenew.com AEM HTL Read–Eval–Print Loop ● To try out basic HTL, a live execution environment called the Read Eval Print Loop can be used. ● Download Link & documentation: https://github.com/Adobe-Marketing-Cloud/aem-htl-repl ● After package installation, go to /content/repl.html ?
  • 7. www.tothenew.com HTL Syntax • Every HTL file is an HTML5 document or fragment, augmented with a specific syntax that adds the dynamic functionality. There are two different kind of Syntaxes:- • HTL Block Statements:- To define structural block elements within HTL file, HTL employs HTML5 data attributes. This allows to attach behavior to existing HTML elements. Block statements can't be used inside html comments, style n script elements. A block statement starts with data- sly. • HTL Expressions:- HTL expressions are delimited by characters ${ and }. At runtime, these expressions are evaluated and their value is injected into the outgoing HTML stream. Expressions can only be used in attribute values, in element content, or in comments.
  • 9. www.tothenew.com Useful Objects Available • properties • pageProperties • Component • currentDesign • currentPage • log • out • pageManager • request • resource • response • sling • wcmmode
  • 10. www.tothenew.com Comments HTL comments are HTML comments with additional syntax. They are delimited like this: <!--/* A HTL Comment */--> However, the content of standard HTML comments, delimited like this: <!-- An HTML Comment --> will be passed through the HTL processor and expressions within the comment will be evaluated.
  • 11. www.tothenew.com HTL Block Statements ● dat-sly-test ● data-sly-resource ● data-sly-include ● data-sly-attribute ● data-sly-element & data-sly-text ● data-sly-list ● data-sly-template & dat-sly-call ● data-sly-use ● data-sly-unwrap
  • 12. www.tothenew.com data-sly-test • Conditionally removes the host element and it‘s content if an expression evaluates to false. • Values that can be converted to false are: undefined variables, null values, the number zero, and empty strings. • data-sly-test also supports the naming and reuse of tests. Example <div data-sly-test.author="${wcmmode.edit || wcmmode.design}"> Show this to the author </div> <div data-sly-test="${!author}"> Not in author mode anymore.. </div>
  • 13. www.tothenew.com • data-sly-include : Includes the output of a rendering script run with the current context, passing back control to the current Sightly script. <div data-sly-include="template.html"></div> <div data-sly-include="template.jsp"></div> • The element on which a data-sly-include has been set is ignored and not displayed data-sly-include
  • 14. www.tothenew.com data-sly-resource • Includes a rendered resource from the same server, using an absolute or relative path. Examples: <div data-sly-resource="${ @path='par', resourceType='foundation/components/parsys'}"/> With an expression more options can be specified: <section data-sly-resource="${'my/path' @ appendPath='appended/path'}"></section> <section data-sly-resource="${'my/path' @ prependPath='prepended/path'}"></section> Manipulating selectors: <section data-sly-resource="${'my/path' @ selectors='selector1.selector2'}" /> <section data-sly-resource="${'my/path' @ addSelectors=['selector1', 'selector2']}" /> <section data-sly-resource="${'my/path' @removeSelectors=['selector1','selector2']}" /> By default, the AEM decoration tags are disabled, the decorationTagName option allows to bring them back, and the cssClassName to add classes to that element. <article data-sly-resource="${'path/to/resource' @ decorationTagName='span', cssClassName='className'}"></article>
  • 15. www.tothenew.com data-sly-attribute • Sets an attribute or a group of attributes on the current element : <tag class="className" data-sly-attribute.class="${myVar}"></tag> This overwrites the content of the class attribute Assuming that foobar = {'id' : 'foo', 'class' : 'bar'} , <input data-sly-attribute="${foobar}" type="text"/> outputs : <input id="foo" class="bar" type="text"/> • Attributes are processed left-to-right : <div class="bar1" data-sly-attribute.class="bar2" data-sly- attribute="${foobar}"></div> outputs: <div id="foo" class="bar"></div>
  • 16. www.tothenew.com • Changes the element, mostly useful for setting element tags like h1..h6, th, td, ol, ul : <div data-sly-element"${'h1'}">Sightly Element Example</div> outputs: <h1>Sightly Element Example</h1> For security reasons, data-sly-element accepts only the following element names: a abbr address article aside b bdi bdo blockquote br caption cite code col colgroup data dd del dfn div dl dt em figcaption figure footer h1 h2 h3 h4 h5 h6 header i ins kbd li main mark nav ol p pre q rp rt ruby s samp section small span strong sub sup table tbody td tfoot th thead time tr u var wbr data-sly-text • Replaces the content of its host element with the specified text. <p data-sly-text="${properties.jcr:description}">Lorem ipsum</p> data-sly-element
  • 17. www.tothenew.com data-sly-list ● Repeats the content of the host element for each property in the provided object. <ul data-sly-list="${currentPage.listChildren}"> <li> index: ${itemList.index}, value: ${item.title} </li> </ul> <ul data-sly-list.child="${myObj}"> <li> key: ${child}, value: ${myObj[child]} </li> </ul> ● itemList holds the following properties: index: zero-based counter (0..length-1). count: one-based counter (1..length). first: true if the current item is the first item. middle: true if the current item is neither the first nor the last item. last: true if the current item is the last item. odd: true if index is odd. even: true if index is even.
  • 18. www.tothenew.com ● Template blocks can be used like function calls: ○ Parameters can be passed when calling templates. ○ They also allow recursion. ● Template Declaration : <template data-sly-template.example="${@ class, text}"> <span class="${class}">${text}</span> </template> ● Call Statement : <div data-sly-call="${example @ class=‘css-class', text='Hi'}"></div> ● Output: <div><span class="css-class">Hi</span></div> Template & Call Statements
  • 19. www.tothenew.com • Initializes a helper object (defined in JavaScript or Java) and exposes it through a variable: JS: <div data-sly-use.page="customPage.js">${page.foo}</div> Java: <div data-sly-use.nav="Navigation">${nav.foo}</div> • Parameters can be passed to the Use-API by using expression options: <div data-sly-use.nav="${'Navigation' @ depth=1,showVisible=!wcmmode.edit}"> ${nav.foo} </div> • Also used to load data-sly-template markup snippets located in a different file : data-sly-use <!-- 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>
  • 20. www.tothenew.com HTL Use-API Java Use-API JavaScript Use-API Pros ● faster ● can be inspected with a debugger ● easy to unit-test ● can be modified by front-end developers ● is located within the component, keeping the view logic of a component close to its corresponding template
  • 21. www.tothenew.com Java Use-API enables a HTL file to access helper methods in a custom Java class. 1. Implementing Use interface: public class HTLComponent implements Use { @Override public void init(Bindings bindings) { Resource resource = (Resource)bindings.get("resource"); ValueMap properties = (ValueMap)bindings.get("properties"); // Parameters passed to the use-class String param1 = (String) bindings.get("param1"); } In AEM 6.2, io.sightly.java.api.Use is deprecated, org.apache.sling.scripting.sightly.pojo.Use is used instead. Java Use-API
  • 22. www.tothenew.com Java Use-API 2. Extend WCMUsePojo class: public class HTLComponent extends WCMUsePojo { private String myTitle; @Override public void activate() { String text = get("text", String.class); myTitle = "My Project " + text + getCurrentPage().getTitle() + “ : ” + getProperties().get("title", ""); } public String getMyTitle() { return myTitle; } } In AEM 6.2, WCMUse is deprecated, com.adobe.cq.sightly.WCMUsePojo used instead.
  • 23. www.tothenew.com • If the Java source file is in the same folder as the HTL file <div data-sly-use.nav="Navigation">${nav.foo}</div> Otherwise, <div data-sly-use.nav="com.htl.model.Navigation">${nav.foo}</div> • HTL Use-API resolution Find a Java UseClass in the same directory OR with a fully qualified class name Try to adapt the current Resource/Request to UseClass, if unsuccessful, try to instantiate UseClass with a zero-argument constructor. Within HTL, bind the newly adapted or created object to the localName. If UseClass implements the Use interface then call the init method, passing the current execution context (a javax.scripting.Bindings object). UseClass extending WCMUse is a special case of implementing Use providing the convenience context methods and its activate method is automatically called from Use.init. If UseClass is a path to a HTL file containing a data-sly-template, prepare the template. Otherwise, if UseClass is a path to a JavaScript use-class, prepare the use-class. data-sly-use (cont.)
  • 24. www.tothenew.com • Enables a HTL file to access helper code written in JavaScript. • Allows all complex business logic to be encapsulated in the JavaScript code, while the HTL code deals only with direct markup production. use(function () { var Constants = { DESCRIPTION_PROP: "jcr:description", DESCRIPTION_LENGTH: 50 }; var title = currentPage.getNavigationTitle() || currentPage.getTitle() || currentPage.getName(); var description = properties.get(Constants.DESCRIPTION_PROP, "").substr(0, Constants.DESCRIPTION_LENGTH); return { title: title, description: description }; }); data-sly-use JavaScript Use Api
  • 25. www.tothenew.com Client libraries helper template library The client libraries helper template library (/libs/granite/HTL/templates/clientlib.html) can be loaded through data-sly-use and stored in a clientLib block element variable. Loading the library's CSS style sheets and JavaScript is done through data-sly-call. The clientLib template library exposes three templates: • css - loads only the CSS files of the referenced client libraries • js - loads only the JavaScript files of the referenced client libraries • all - loads all the files of the referenced client libraries
  • 26. www.tothenew.com Client libraries helper template library Example <head data-sly- use.clientLib="${'/libs/granite/HTL/templates/clientlib.html'}"> <css data-sly-call="${clientLib.css @ categories=['category1', 'category2']}" data-sly-unwrap/> </head> <body> <!-- content --> <js data-sly-call="${clientLib.js @ categories=['category1', 'category2']}" data-sly-unwrap/> </body>
  • 27. www.tothenew.com • The <sly> HTML tag can be used to remove the current element, allowing only its children to be displayed: <sly data-sly-test="${event.hasDate}" > <span>Hello</span> </sly> • Its functionality is similar to the data-sly-unwrap block element : <div data-sly-test="${event.hasDate}" data-sly-unwrap> <span>Hello</span> </div> Both Output : <span>Hello</span> • Although not a valid HTML 5 tag, the <sly> tag can be displayed in the final output using data-sly-unwrap: <sly data-sly-unwrap="${false}"></sly> outputs: <sly></sly> <sly> & data-sly-unwrap
  • 29. www.tothenew.com Display Context Option The context option offers control over escaping and XSS protection. • Allowing some HTML markup (filtering out scripts) <div>${‘<p>Hello</p>’ @ context='html'}</div> Without context : &lt;p&gt;hello&lt;/p&gt; • Adding URI validation protection <p data-link="${link @ context='uri'}">text</p> • Applying CSS string escaping <style> a { font-family: "${myFont @ context='styleString'}"; } </style>
  • 30. www.tothenew.com Display Context Option Context Use • html • text • elementName • uri • scriptString • scriptComment • scriptRegExp • styleString • styleComment • comment • number • unsafe Outputs HTML - Removes markup that may contain XSS risks For simple HTML content - Encodes all HTML Allows only element names that are white-listed, else outputs 'div' To get valid Href link or path Applies JavaScript string escaping For JavaScript block comments To apply JavaScript regular expression escaping To apply CSS string escaping For CSS comments To apply HTML comment escaping Outputs zero if the value is not a number Disables XSS protection completely, use this at your own risk.
  • 31. www.tothenew.com String Format Option Numbered parameters can be used for injecting variables: ${'Assets {0}' @ format=properties.assetName} OR ${'Assets {0}' @ format=[properties.assetName]} ${'Page {0} of {1}' @ format=[current, total]} Array Join Option The join option allows to control the output of an ahorray object by specifying the separator string. This can for e.g. be useful for setting class-names ${['one', 'two'] @ join='; '} <!--/* outputs: one; two */--> <span class="${myListOfClassNames @ join=' '}"></span>
  • 32. www.tothenew.com Internationalization (@i18n) To translate a string to the resource language: ${'Assets' @ i18n} Two more options can be used with i18n: • locale : Overrides the language from the source. For e.g.: en-US or fr-CH • hint : Allows to provide some information about the context for the translators. ${'Assets' @ i18n, locale='en-US', hint='Translation Hint'}
  • 33. www.tothenew.com URI Manipulation • Scheme - Allows adding or removing the scheme part for a URI : ${'example.com/path/page.html' @ scheme='http'} outputs: http://example.com/path/page.html ${'http://example.com/path/page.html' @ scheme='https'} outputs: https://example.com/path/page.html • Domain - Allows adding or replacing the host and port (domain) part for a URI : ${'///path/page.html' @ domain='example.org'} outputs: //example.org/path/page.html ${'http://www.example.com/path/page.html' @ domain='www.example.org'} outputs: http://www.example.org/path/page.html
  • 34. www.tothenew.com URI Manipulation Path / prependPath / appendPath – Modify the path that identifies a resource : ${'http://example.com/this/one.selector.html/suffix?key=value’@ path='that/two'} outputs: http://example.com/that/two.selector.html/suffix?key=value# ${'http://example.com/this/one.selector.html/suffix?key=value' @ path=‘’} outputs: http://example.com/this/one.selector.html/suffix?key=value ${'path' @ prependPath='..'} outputs: ../path ${'http://example.com/path/page.html' @ prependPath='foo'} outputs: http://example.com/foo/path/page.html ${'one' @ appendPath='two'} outputs: one/two
  • 35. www.tothenew.com URI Manipulation Selectors / addSelectors / removeSelectors - Modifies or removes the selectors from a URI: ${'path/page.woo.foo.html' @ selectors='foo.bar'} outputs: path/page.foo.bar.html ${'path/page.woo.foo.html' @ selectors=['foo', 'bar']} outputs: path/page.foo.bar.html ${'path/page.woo.foo.html' @ addSelectors='foo.bar'} outputs: path/page.woo.foo.bar.html ${'path/page.woo.foo.html' @ removeSelectors=['foo', 'bar']} outputs: path/page.woo.html
  • 36. www.tothenew.com URI Manipulation query / addQuery / removeQuery- adds, replaces or removes the query segment of a URI, depending on the contents of its map value : assuming that jsuse.query evaluates to: { "query": { "q" : "sightly", "array" : [1, 2, 3] } } ${'http://www.example.org/search' @ query=jsuse.query} outputs: http://www.example.org/search?q=sightly&amp;array=1&amp;array=2&amp;array=3 ${'http://www.example.org/search?s=1' @ addQuery=jsuse.query} outputs: http://www.example.org/search?s=1&amp;q=sightly&amp;array=1&amp;array=2&amp;arra y=3 ${'http://www.example.org/search?s=1&q=sightly' @ removeQuery=['s', 'q']} outputs: http://www.example.org/search
  • 37. www.tothenew.com URI Manipulation • Extension - adds, modifies or removes the extension from a URI: ${'path/page.json?key=value' @ extension='html'} outputs: path/page.html?key=value ${'path/page.json#fragment' @ extension='html'} outputs: path/page.html#fragment • fragment - adds, modifies or replaces the fragment segment of a URI : ${'path/page' @ fragment='fragment'} outputs: path/page#fragment ${'path/page#one' @ fragment='two'} outputs: path/page#two ${'path/page#one' @ fragment} outputs: path/page
  • 38. www.tothenew.com Best practices ● Abuse of sly ● HTL comments instead of Html comments ● Reuse code using templates ● Use api to be used only when the HTL file alone is not enough to implement logic ● Javascript use is slower than Java use class so use Javascript only for less intensive logic ● Use local java use class if the class is used only for that component, otherwise create a bundle use class ● Passing a parameter to a use-class should only be done when the use- class is used in a data-sly-template file which itself is called from another HTL file with parameters that need to be passed on.
  • 39. www.tothenew.com Moving from JSP to HTL • Components written in HTL are compatible with components written in JSP or ESP. A JSP can include a HTL file like this, • <cq:include script="footer.html"/> and a HTL file can include a JSP like this, <div data-sly-include="footer.jsp"></div>
  • 40. www.tothenew.com • HTL Specification : https://docs.adobe.com/docs/en/htl/overview.html https://github.com/Adobe-Marketing-Cloud/sightly- spec/blob/master/SPECIFICATION.md#31-sly • Gabriel Walt’s Slideshare PPT: http://www.slideshare.net/GabrielWalt/component-development • http://www.netcentric.biz/blog/2015/08/aem-sightly-style-guide.html • http://www.citytechinc.com/content/dam/circuit/Component%20Development.pd f • http://stackoverflow.com/questions/27583326/expression-option-sightly References