SlideShare a Scribd company logo
APACHE SLING & FRIENDS TECH MEETUP
BERLIN, 26-28 SEPTEMBER 2016
Sightly HTL Compilers and Tooling
rev 3.20160926
@raducotescu
Apache Sling PMC member
Computer Scientist @ Adobe Systems
radu@apache.org
adaptTo()
HTL Compilers and Tooling
2
What’s changed since last September?
1. Sightly has been renamed

https://docs.adobe.com/content/docs/en/htl/update.html

adaptTo()
HTL Compilers and Tooling
3
What’s changed since last September?
2. Version 1.2 of the HTL language specification was released on March 30th, 2016:

• enums can now be used in comparisons



<div data-sly-test=“{enumConstant == ‘CONSTANT_NAME’}”></div>



adaptTo()
HTL Compilers and Tooling
4
What’s changed since last September?
3. Sling-level improvements: Resource objects can now be used directly in

data-sly-resource:



<sly data-sly-resource=“${myResource}”/>
adaptTo()
HTL Compilers and Tooling
5
What’s changed since last September?
3. Sling-level improvements: Resource objects can be used directly in the Use-API



<sly data-sly-use.myRes=“${'some/path'}">

${myRes.title}

</sly>
adaptTo()
HTL Compilers and Tooling
6
What’s changed since last September?
3. Sling-level improvements: request attributes can be passed in both data-sly-
resource and data-sly-include:



<sly data-sly-include="${'script.html' @
requestAttributes=helper.attributesMap}"/>

<sly data-sly-resource="${'some/path' @
resourceType='some/type',
requestAttributes=helper.attributesMap}"/>
adaptTo()
HTL Compilers and Tooling
7
What’s changed since last September?
4. The org.apache.sling.scripting.sightly module has now evolved into
3 modules:



org.apache.sling.scripting.sightly.compiler



org.apache.sling.scripting.sightly.compiler.java



org.apache.sling.scripting.sightly - now just the
ScriptEngine + runtime
The HTL Compiler
adaptTo() 8
adaptTo()
HTL Compilers and Tooling
9
The HTL Compiler (aka The Front End
HTL Compiler)

1. compiles HTL into an Abstract Syntax Tree
(almost; it’s actually an Abstract Semantic Graph)
adaptTo()
HTL Compilers and Tooling
10
The HTL Compiler (aka The Front End HTL Compiler)
2. provides a warnings and errors report with information about where they
occurred into the original script



CompilationResult result =
compiler.compile(compilationUnit, backendCompiler);

for (CompilerMessage m : result.getErrors()) {

// do stuff

}

adaptTo()
HTL Compilers and Tooling
11
The HTL Compiler (aka The Front End HTL Compiler)
3. exposes an API into which back end compilers can be hooked

o.a.s.scripting.sightly.compiler
o.a.s.scripting.sightly.compiler.backend
o.a.s.scripting.sightly.compiler.commands
o.a.s.scripting.sightly.compiler.expression
o.a.s.scripting.sightly.compiler.expression.nodes
o.a.s.scripting.sightly.compiler.util
The HTL Java Compiler
adaptTo() 12
adaptTo()
HTL Compilers and Tooling
13
The HTL Java Compiler (aka The Back
End HTL Compiler)
1. implements a back end compiler which can be
hooked into the HTL Compiler to generate Java
code
adaptTo()
HTL Compilers and Tooling
14
The HTL Java Compiler (aka The Back End HTL Compiler)
2. provides the Java Runtime API



org.apache.sling.scripting.sightly

org.apache.sling.scripting.sightly.extension

org.apache.sling.scripting.sightly.java.compiler

org.apache.sling.scripting.sightly.pojo

org.apache.sling.scripting.sightly.render

org.apache.sling.scripting.sightly.use
adaptTo()
HTL Compilers and Tooling
15
The HTL Java Compiler (aka The Back End HTL Compiler)
3. generates Java classes that use the Runtime API to which a custom
org.apache.sling.scripting.sightly.render.RenderContext
implementation can be provided for rendering the compiled HTL scripts
adaptTo()
HTL Compilers and Tooling
16
AST
adaptTo()
HTL Compilers and Tooling
17
Both compilers:
• are OSGi bundles for convenience
• can also be used in non-OSGi environments - you just have to manually instantiate
the two compilers
• are independent of the Sling API, which would allow them to be used in
combination with other frameworks / platforms or even other scripting /
programming languages
The HTL Maven Plugin
adaptTo() 18
adaptTo()
HTL Compilers and Tooling
19
The HTL Maven Plugin
<plugin>

<groupId>org.apache.sling</groupId>

<artifactId>htl-maven-plugin</artifactId>
<version>1.0.0</version>

<executions>

<execution>

<id>validate-scripts</id>

<goals>

<goal>validate</goal>

</goals>

<phase>compile</phase>

</execution>

</executions>

</plugin>
adaptTo()
HTL Compilers and Tooling
20
The HTL Maven Plugin
1. its only life goal is to validate your scripts 🙃 

mvn htl:validate

2. it has the following configuration options:

sourceDirectory - defaults to ${project.build.sourceDirectory}

includes - defaults to **/*.html

excludes

failOnWarnings - defaults to false
adaptTo()
HTL Compilers and Tooling
21
The HTL Maven Plugin
3. it’s also compatible with M2Eclipse - warnings and errors are available in the
Markers view in Eclipse (thanks to @rombert)
adaptTo()
HTL Compilers and Tooling
22
adaptTo()
HTL Compilers and Tooling
23
Credits & Resources
Captain Obvious - http://captainobvious.website/
HTL - https://github.com/apache/sling/tree/trunk/bundles/scripting/sightly
HTL Maven Plugin - https://sling.apache.org/documentation/development/htl-
maven-plugin.html

More Related Content

Similar to HTL Compilers and Tooling

Paving the way to a native Sling
Paving the way to a native SlingPaving the way to a native Sling
Paving the way to a native Sling
Radu Cotescu
 
Modern Web Applications with Sightly
Modern Web Applications with SightlyModern Web Applications with Sightly
Modern Web Applications with Sightly
Radu Cotescu
 
Android application architecture
Android application architectureAndroid application architecture
Android application architecture
Romain Rochegude
 
Angular 2 Crash Course
Angular  2 Crash CourseAngular  2 Crash Course
Angular 2 Crash Course
Elisha Kramer
 
Kube cfg-mgmt
Kube cfg-mgmtKube cfg-mgmt
Kube cfg-mgmt
Lee Briggs
 
Kubecon SIG Apps December 2017 Update
Kubecon SIG Apps December 2017 UpdateKubecon SIG Apps December 2017 Update
Kubecon SIG Apps December 2017 Update
Matthew Farina
 
AtoZ about TYPO3 v8 CMS
AtoZ about TYPO3 v8 CMSAtoZ about TYPO3 v8 CMS
AtoZ about TYPO3 v8 CMS
NITSAN Technologies Pvt Ltd
 
New and cool in OSGi R7 - David Bosschaert & Carsten Ziegeler
New and cool in OSGi R7 - David Bosschaert & Carsten ZiegelerNew and cool in OSGi R7 - David Bosschaert & Carsten Ziegeler
New and cool in OSGi R7 - David Bosschaert & Carsten Ziegeler
mfrancis
 
TiConf EU 2014
TiConf EU 2014TiConf EU 2014
TiConf EU 2014
Ingo Muschenetz
 
Moduarlity patterns with OSGi
Moduarlity patterns with OSGiModuarlity patterns with OSGi
Moduarlity patterns with OSGi
Paul Bakker
 
Apache Shindig, from Server Side Portlets to Open Social Gadgets
Apache Shindig, from Server Side Portlets to Open Social GadgetsApache Shindig, from Server Side Portlets to Open Social Gadgets
Apache Shindig, from Server Side Portlets to Open Social Gadgets
Tyrell Perera
 
Crafting APIs
Crafting APIsCrafting APIs
Crafting APIs
Tatiana Al-Chueyr
 
Improving the Accumulo User Experience
 Improving the Accumulo User Experience Improving the Accumulo User Experience
Improving the Accumulo User Experience
Accumulo Summit
 
Give your Foreman a greater toolbox with Plugins - Dirk Goetz - Foreman Birth...
Give your Foreman a greater toolbox with Plugins - Dirk Goetz - Foreman Birth...Give your Foreman a greater toolbox with Plugins - Dirk Goetz - Foreman Birth...
Give your Foreman a greater toolbox with Plugins - Dirk Goetz - Foreman Birth...
NETWAYS
 
Announcing Pebble SDK 2.0
Announcing Pebble SDK 2.0Announcing Pebble SDK 2.0
Announcing Pebble SDK 2.0
Pebble Technology
 
Introducing Pebble SDK 2.0
Introducing Pebble SDK 2.0Introducing Pebble SDK 2.0
Introducing Pebble SDK 2.0
Cherie Williams
 
Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with Python
Brian Lyttle
 
Elyra - a set of AI-centric extensions to JupyterLab Notebooks.
Elyra - a set of AI-centric extensions to JupyterLab Notebooks.Elyra - a set of AI-centric extensions to JupyterLab Notebooks.
Elyra - a set of AI-centric extensions to JupyterLab Notebooks.
Luciano Resende
 
A DevOps guide to Kubernetes
A DevOps guide to KubernetesA DevOps guide to Kubernetes
A DevOps guide to Kubernetes
Paul Czarkowski
 
Moved to https://slidr.io/azzazzel/leveraging-osgi-to-create-extensible-plugi...
Moved to https://slidr.io/azzazzel/leveraging-osgi-to-create-extensible-plugi...Moved to https://slidr.io/azzazzel/leveraging-osgi-to-create-extensible-plugi...
Moved to https://slidr.io/azzazzel/leveraging-osgi-to-create-extensible-plugi...
Milen Dyankov
 

Similar to HTL Compilers and Tooling (20)

Paving the way to a native Sling
Paving the way to a native SlingPaving the way to a native Sling
Paving the way to a native Sling
 
Modern Web Applications with Sightly
Modern Web Applications with SightlyModern Web Applications with Sightly
Modern Web Applications with Sightly
 
Android application architecture
Android application architectureAndroid application architecture
Android application architecture
 
Angular 2 Crash Course
Angular  2 Crash CourseAngular  2 Crash Course
Angular 2 Crash Course
 
Kube cfg-mgmt
Kube cfg-mgmtKube cfg-mgmt
Kube cfg-mgmt
 
Kubecon SIG Apps December 2017 Update
Kubecon SIG Apps December 2017 UpdateKubecon SIG Apps December 2017 Update
Kubecon SIG Apps December 2017 Update
 
AtoZ about TYPO3 v8 CMS
AtoZ about TYPO3 v8 CMSAtoZ about TYPO3 v8 CMS
AtoZ about TYPO3 v8 CMS
 
New and cool in OSGi R7 - David Bosschaert & Carsten Ziegeler
New and cool in OSGi R7 - David Bosschaert & Carsten ZiegelerNew and cool in OSGi R7 - David Bosschaert & Carsten Ziegeler
New and cool in OSGi R7 - David Bosschaert & Carsten Ziegeler
 
TiConf EU 2014
TiConf EU 2014TiConf EU 2014
TiConf EU 2014
 
Moduarlity patterns with OSGi
Moduarlity patterns with OSGiModuarlity patterns with OSGi
Moduarlity patterns with OSGi
 
Apache Shindig, from Server Side Portlets to Open Social Gadgets
Apache Shindig, from Server Side Portlets to Open Social GadgetsApache Shindig, from Server Side Portlets to Open Social Gadgets
Apache Shindig, from Server Side Portlets to Open Social Gadgets
 
Crafting APIs
Crafting APIsCrafting APIs
Crafting APIs
 
Improving the Accumulo User Experience
 Improving the Accumulo User Experience Improving the Accumulo User Experience
Improving the Accumulo User Experience
 
Give your Foreman a greater toolbox with Plugins - Dirk Goetz - Foreman Birth...
Give your Foreman a greater toolbox with Plugins - Dirk Goetz - Foreman Birth...Give your Foreman a greater toolbox with Plugins - Dirk Goetz - Foreman Birth...
Give your Foreman a greater toolbox with Plugins - Dirk Goetz - Foreman Birth...
 
Announcing Pebble SDK 2.0
Announcing Pebble SDK 2.0Announcing Pebble SDK 2.0
Announcing Pebble SDK 2.0
 
Introducing Pebble SDK 2.0
Introducing Pebble SDK 2.0Introducing Pebble SDK 2.0
Introducing Pebble SDK 2.0
 
Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with Python
 
Elyra - a set of AI-centric extensions to JupyterLab Notebooks.
Elyra - a set of AI-centric extensions to JupyterLab Notebooks.Elyra - a set of AI-centric extensions to JupyterLab Notebooks.
Elyra - a set of AI-centric extensions to JupyterLab Notebooks.
 
A DevOps guide to Kubernetes
A DevOps guide to KubernetesA DevOps guide to Kubernetes
A DevOps guide to Kubernetes
 
Moved to https://slidr.io/azzazzel/leveraging-osgi-to-create-extensible-plugi...
Moved to https://slidr.io/azzazzel/leveraging-osgi-to-create-extensible-plugi...Moved to https://slidr.io/azzazzel/leveraging-osgi-to-create-extensible-plugi...
Moved to https://slidr.io/azzazzel/leveraging-osgi-to-create-extensible-plugi...
 

Recently uploaded

Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
Aftab Hussain
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
Hornet Dynamics
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Łukasz Chruściel
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Neo4j
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
Green Software Development
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
Gerardo Pardo-Castellote
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
SOCRadar
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 

Recently uploaded (20)

Vitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdfVitthal Shirke Java Microservices Resume.pdf
Vitthal Shirke Java Microservices Resume.pdf
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of CodeA Study of Variable-Role-based Feature Enrichment in Neural Models of Code
A Study of Variable-Role-based Feature Enrichment in Neural Models of Code
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket ManagementUtilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
Utilocate provides Smarter, Better, Faster, Safer Locate Ticket Management
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
E-commerce Application Development Company.pdf
E-commerce Application Development Company.pdfE-commerce Application Development Company.pdf
E-commerce Application Development Company.pdf
 
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️Need for Speed: Removing speed bumps from your Symfony projects ⚡️
Need for Speed: Removing speed bumps from your Symfony projects ⚡️
 
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissancesAtelier - Innover avec l’IA Générative et les graphes de connaissances
Atelier - Innover avec l’IA Générative et les graphes de connaissances
 
Energy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina JonuziEnergy consumption of Database Management - Florina Jonuzi
Energy consumption of Database Management - Florina Jonuzi
 
DDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systemsDDS-Security 1.2 - What's New? Stronger security for long-running systems
DDS-Security 1.2 - What's New? Stronger security for long-running systems
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 
socradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdfsocradar-q1-2024-aviation-industry-report.pdf
socradar-q1-2024-aviation-industry-report.pdf
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 

HTL Compilers and Tooling

  • 1. APACHE SLING & FRIENDS TECH MEETUP BERLIN, 26-28 SEPTEMBER 2016 Sightly HTL Compilers and Tooling rev 3.20160926 @raducotescu Apache Sling PMC member Computer Scientist @ Adobe Systems radu@apache.org
  • 2. adaptTo() HTL Compilers and Tooling 2 What’s changed since last September? 1. Sightly has been renamed
 https://docs.adobe.com/content/docs/en/htl/update.html

  • 3. adaptTo() HTL Compilers and Tooling 3 What’s changed since last September? 2. Version 1.2 of the HTL language specification was released on March 30th, 2016:
 • enums can now be used in comparisons
 
 <div data-sly-test=“{enumConstant == ‘CONSTANT_NAME’}”></div>
 

  • 4. adaptTo() HTL Compilers and Tooling 4 What’s changed since last September? 3. Sling-level improvements: Resource objects can now be used directly in
 data-sly-resource:
 
 <sly data-sly-resource=“${myResource}”/>
  • 5. adaptTo() HTL Compilers and Tooling 5 What’s changed since last September? 3. Sling-level improvements: Resource objects can be used directly in the Use-API
 
 <sly data-sly-use.myRes=“${'some/path'}">
 ${myRes.title}
 </sly>
  • 6. adaptTo() HTL Compilers and Tooling 6 What’s changed since last September? 3. Sling-level improvements: request attributes can be passed in both data-sly- resource and data-sly-include:
 
 <sly data-sly-include="${'script.html' @ requestAttributes=helper.attributesMap}"/>
 <sly data-sly-resource="${'some/path' @ resourceType='some/type', requestAttributes=helper.attributesMap}"/>
  • 7. adaptTo() HTL Compilers and Tooling 7 What’s changed since last September? 4. The org.apache.sling.scripting.sightly module has now evolved into 3 modules:
 
 org.apache.sling.scripting.sightly.compiler
 
 org.apache.sling.scripting.sightly.compiler.java
 
 org.apache.sling.scripting.sightly - now just the ScriptEngine + runtime
  • 9. adaptTo() HTL Compilers and Tooling 9 The HTL Compiler (aka The Front End HTL Compiler)
 1. compiles HTL into an Abstract Syntax Tree (almost; it’s actually an Abstract Semantic Graph)
  • 10. adaptTo() HTL Compilers and Tooling 10 The HTL Compiler (aka The Front End HTL Compiler) 2. provides a warnings and errors report with information about where they occurred into the original script
 
 CompilationResult result = compiler.compile(compilationUnit, backendCompiler);
 for (CompilerMessage m : result.getErrors()) {
 // do stuff
 }

  • 11. adaptTo() HTL Compilers and Tooling 11 The HTL Compiler (aka The Front End HTL Compiler) 3. exposes an API into which back end compilers can be hooked
 o.a.s.scripting.sightly.compiler o.a.s.scripting.sightly.compiler.backend o.a.s.scripting.sightly.compiler.commands o.a.s.scripting.sightly.compiler.expression o.a.s.scripting.sightly.compiler.expression.nodes o.a.s.scripting.sightly.compiler.util
  • 12. The HTL Java Compiler adaptTo() 12
  • 13. adaptTo() HTL Compilers and Tooling 13 The HTL Java Compiler (aka The Back End HTL Compiler) 1. implements a back end compiler which can be hooked into the HTL Compiler to generate Java code
  • 14. adaptTo() HTL Compilers and Tooling 14 The HTL Java Compiler (aka The Back End HTL Compiler) 2. provides the Java Runtime API
 
 org.apache.sling.scripting.sightly
 org.apache.sling.scripting.sightly.extension
 org.apache.sling.scripting.sightly.java.compiler
 org.apache.sling.scripting.sightly.pojo
 org.apache.sling.scripting.sightly.render
 org.apache.sling.scripting.sightly.use
  • 15. adaptTo() HTL Compilers and Tooling 15 The HTL Java Compiler (aka The Back End HTL Compiler) 3. generates Java classes that use the Runtime API to which a custom org.apache.sling.scripting.sightly.render.RenderContext implementation can be provided for rendering the compiled HTL scripts
  • 16. adaptTo() HTL Compilers and Tooling 16 AST
  • 17. adaptTo() HTL Compilers and Tooling 17 Both compilers: • are OSGi bundles for convenience • can also be used in non-OSGi environments - you just have to manually instantiate the two compilers • are independent of the Sling API, which would allow them to be used in combination with other frameworks / platforms or even other scripting / programming languages
  • 18. The HTL Maven Plugin adaptTo() 18
  • 19. adaptTo() HTL Compilers and Tooling 19 The HTL Maven Plugin <plugin>
 <groupId>org.apache.sling</groupId>
 <artifactId>htl-maven-plugin</artifactId> <version>1.0.0</version>
 <executions>
 <execution>
 <id>validate-scripts</id>
 <goals>
 <goal>validate</goal>
 </goals>
 <phase>compile</phase>
 </execution>
 </executions>
 </plugin>
  • 20. adaptTo() HTL Compilers and Tooling 20 The HTL Maven Plugin 1. its only life goal is to validate your scripts 🙃 
 mvn htl:validate
 2. it has the following configuration options:
 sourceDirectory - defaults to ${project.build.sourceDirectory}
 includes - defaults to **/*.html
 excludes
 failOnWarnings - defaults to false
  • 21. adaptTo() HTL Compilers and Tooling 21 The HTL Maven Plugin 3. it’s also compatible with M2Eclipse - warnings and errors are available in the Markers view in Eclipse (thanks to @rombert)
  • 23. adaptTo() HTL Compilers and Tooling 23 Credits & Resources Captain Obvious - http://captainobvious.website/ HTL - https://github.com/apache/sling/tree/trunk/bundles/scripting/sightly HTL Maven Plugin - https://sling.apache.org/documentation/development/htl- maven-plugin.html