12
APACHE SLING & FRIENDS TECH MEETUP BERLIN, 23-25 SEPTEMBER 2013 Don’t mess with your view! Gabriel Walt, Product Manager, AEM Senol Tas, Sr. Computer Scientist, A@A Honwai Wong, Developer, adobe.com

adaptTo() 2013 – AEM Templating with Sightly (concept name)

Embed Size (px)

DESCRIPTION

OUTDATED: please have a look at following newer presentation on the same topic: http://www.slideshare.net/GabrielWalt/component-development Don’t mess with your view! An HTML Template Library for: - Clean component development with a clear separation of concerns. - Valid and readable markup through HTML5 annotation. - Security with HTML context aware XSS protection.

Citation preview

Page 1: adaptTo() 2013 – AEM Templating with Sightly (concept name)

APACHE SLING & FRIENDS TECH MEETUP BERLIN, 23-25 SEPTEMBER 2013

Don’t mess with your view! Gabriel Walt, Product Manager, AEM

Senol Tas, Sr. Computer Scientist, A@A Honwai Wong, Developer, adobe.com

Page 2: adaptTo() 2013 – AEM Templating with Sightly (concept name)

New Component Model

adaptTo() 2013 2

HTML Template Library

Page 3: adaptTo() 2013 – AEM Templating with Sightly (concept name)

New Component Model

adaptTo() 2013 3

Make AEM projects more efficient §  Valid HTML5

§  Intuitive and easy to learn §  Secure by default (built-in XSS protection) §  Enable front-end web developers to build

components for AEM §  Simplify and enforce separation of

concerns between logic and markup

Page 4: adaptTo() 2013 – AEM Templating with Sightly (concept name)

CSS  &  JS  

ClientLib  

New Component Model

adaptTo() 2013 4

CQ  Component  

HTML  template  

Logic  Code  

CSS  &  JS  

ClientLib  

CQ  Component  sling:resourceSuperType  

HTML  template  extends  

Logic  Code  extends  

Page 5: adaptTo() 2013 – AEM Templating with Sightly (concept name)

Architecture

adaptTo() 2013 5

JSP

Page 6: adaptTo() 2013 – AEM Templating with Sightly (concept name)

Markup Annotation

adaptTo() 2013 6

HTML

Page 7: adaptTo() 2013 – AEM Templating with Sightly (concept name)

Building Blocks

adaptTo() 2013 7

Expression

<h1>${properties.jcr:title}</h1>

<h1>${“My title” @i18n}</h1>

<h1>${properties.richText @xss=filterHTML}</h1>

Block Elements

<p data-htl-test=“${wcm.edit}”>Edit mode…</p>

<ul data-htl-list=“${currentPage.listChildren}”><li>${item.name}</li></ul>

<section data-htl-include=“myTemplate.html”/>

Use-API

<div data-htl-use-foo=“MyPojo”><h1>${foo.title}</h1></div>

<div data-htl-use-bar=“classPath.MyClass”><h1>${bar.title}</h1></div>

Page 8: adaptTo() 2013 – AEM Templating with Sightly (concept name)

XSS & URL Magic

adaptTo() 2013 8

Example 1

<a href=“${resource.path}”>${resource.name}</a>

Results in:

<a href=“/content/geometrixx/_jcr_content.html”>jcr&#x3a;content</a>

Example 2

<a href=“${'javascript:history.back()'}”>${'<script>alert()</script>'}</a>

Results in:

<a href=“”>&lt;script&gt;alert&#x28;&#x29;&lt;&#x2f;script&gt;</a>

Example 3

${'<p>Some HTML is ok</p> <script>alert()</script>' @xss='html'}

Results in:

<p>Some HTML is ok</p>

Page 9: adaptTo() 2013 – AEM Templating with Sightly (concept name)

HTML Extension Model

adaptTo() 2013 9

Component 1

<h1>${properties.jcr:title}</h1>

<!-- several things done here… -->

<ul data-htl-list=“${currentPage.listChildren}”>

<li data-htl-id=“item”>${item.properties.jcr:title}</li>

</ul>

Component 2

<template data-htl-extend=“component1”> <li data-htl-id=“item”>

<a href=“${item.path}.html”>${item.properties.jcr:title}</a>

</li>

</template>

Page 10: adaptTo() 2013 – AEM Templating with Sightly (concept name)

Sightly Core Engine

adaptTo() 2013 10

HTML  file   Lexxer   Compiler  

Language  Compiler  callbacks  

Java  

PHP  

JavaScript  

Node.js  

Ruby  

ASP.NET  

Page 11: adaptTo() 2013 – AEM Templating with Sightly (concept name)

Why a new templating system

adaptTo() 2013 11

Main differentiators §  Automatic state-of-the-art XSS protection

§  Well integrated in the Sling component model §  No need to write code for simple output

§  Programming language independent

§  Intended to be open source (Apache License)

Page 12: adaptTo() 2013 – AEM Templating with Sightly (concept name)

adaptTo() 2013 12

Thanks!