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

Celebrity Girls Call Mumbai 9930687706 Unlimited Short Providing Girls Servic...
Celebrity Girls Call Mumbai 9930687706 Unlimited Short Providing Girls Servic...Celebrity Girls Call Mumbai 9930687706 Unlimited Short Providing Girls Servic...
Celebrity Girls Call Mumbai 9930687706 Unlimited Short Providing Girls Servic...
kiara pandey
 
Odoo E-commerce website development guides
Odoo E-commerce website development guidesOdoo E-commerce website development guides
Odoo E-commerce website development guides
jhkdigitalmarketing
 
Comprehensive Vulnerability Assessments Process _ Aardwolf Security.docx
Comprehensive Vulnerability Assessments Process _ Aardwolf Security.docxComprehensive Vulnerability Assessments Process _ Aardwolf Security.docx
Comprehensive Vulnerability Assessments Process _ Aardwolf Security.docx
Aardwolf Security
 
Artificial intelligence in customer services or chatbots
Artificial intelligence  in customer services or chatbotsArtificial intelligence  in customer services or chatbots
Artificial intelligence in customer services or chatbots
kayash1656
 
Girls Call Jogeshwari 9967584737 Provide Best And Top Girl Service And No1 in...
Girls Call Jogeshwari 9967584737 Provide Best And Top Girl Service And No1 in...Girls Call Jogeshwari 9967584737 Provide Best And Top Girl Service And No1 in...
Girls Call Jogeshwari 9967584737 Provide Best And Top Girl Service And No1 in...
simran hot girls
 
TEQnation 2024: Sustainable Software: May the Green Code Be with You
TEQnation 2024: Sustainable Software: May the Green Code Be with YouTEQnation 2024: Sustainable Software: May the Green Code Be with You
TEQnation 2024: Sustainable Software: May the Green Code Be with You
marcofolio
 
Authentication Review-June -2024 AP & TS.pptx
Authentication Review-June -2024 AP & TS.pptxAuthentication Review-June -2024 AP & TS.pptx
Authentication Review-June -2024 AP & TS.pptx
DEMONDUOS
 
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
rachitkumar09887
 
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdfA Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
kalichargn70th171
 
InflectraCON 360: Risk-Based Testing for Mission Critical Systems
InflectraCON 360: Risk-Based Testing for Mission Critical SystemsInflectraCON 360: Risk-Based Testing for Mission Critical Systems
InflectraCON 360: Risk-Based Testing for Mission Critical Systems
Inflectra
 
BATber53 AWS Modernize your applications with purpose-built AWS databases
BATber53 AWS Modernize your applications with purpose-built AWS databasesBATber53 AWS Modernize your applications with purpose-built AWS databases
BATber53 AWS Modernize your applications with purpose-built AWS databases
BATbern
 
UMiami degree offer diploma Transcript
UMiami degree offer diploma TranscriptUMiami degree offer diploma Transcript
UMiami degree offer diploma Transcript
attueb
 
🚂🚘 Premium Girls Call Ranchi 🛵🚡000XX00000 💃 Choose Best And Top Girl Service...
🚂🚘 Premium Girls Call Ranchi  🛵🚡000XX00000 💃 Choose Best And Top Girl Service...🚂🚘 Premium Girls Call Ranchi  🛵🚡000XX00000 💃 Choose Best And Top Girl Service...
🚂🚘 Premium Girls Call Ranchi 🛵🚡000XX00000 💃 Choose Best And Top Girl Service...
bahubalikumar09988
 
Celebrity Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Servic...
Celebrity Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Servic...Celebrity Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Servic...
Celebrity Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Servic...
45unexpected
 
AI - Your Startup Sidekick (Leveraging AI to Bootstrap a Lean Startup).pdf
AI - Your Startup Sidekick (Leveraging AI to Bootstrap a Lean Startup).pdfAI - Your Startup Sidekick (Leveraging AI to Bootstrap a Lean Startup).pdf
AI - Your Startup Sidekick (Leveraging AI to Bootstrap a Lean Startup).pdf
Daniel Zivkovic
 
Il Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazioneIl Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazione
confluent
 
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
 
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in CityGirls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
neshakor5152
 
Amadeus Travel API, Amadeus Booking API, Amadeus GDS
Amadeus Travel API, Amadeus Booking API, Amadeus GDSAmadeus Travel API, Amadeus Booking API, Amadeus GDS
Amadeus Travel API, Amadeus Booking API, Amadeus GDS
aadhiyaeliza
 
AWS DevOps-Tutorial CHANAKYA SRIYAN DUKKA.
AWS DevOps-Tutorial CHANAKYA SRIYAN DUKKA.AWS DevOps-Tutorial CHANAKYA SRIYAN DUKKA.
AWS DevOps-Tutorial CHANAKYA SRIYAN DUKKA.
Srinivas Dukka
 

Recently uploaded (20)

Celebrity Girls Call Mumbai 9930687706 Unlimited Short Providing Girls Servic...
Celebrity Girls Call Mumbai 9930687706 Unlimited Short Providing Girls Servic...Celebrity Girls Call Mumbai 9930687706 Unlimited Short Providing Girls Servic...
Celebrity Girls Call Mumbai 9930687706 Unlimited Short Providing Girls Servic...
 
Odoo E-commerce website development guides
Odoo E-commerce website development guidesOdoo E-commerce website development guides
Odoo E-commerce website development guides
 
Comprehensive Vulnerability Assessments Process _ Aardwolf Security.docx
Comprehensive Vulnerability Assessments Process _ Aardwolf Security.docxComprehensive Vulnerability Assessments Process _ Aardwolf Security.docx
Comprehensive Vulnerability Assessments Process _ Aardwolf Security.docx
 
Artificial intelligence in customer services or chatbots
Artificial intelligence  in customer services or chatbotsArtificial intelligence  in customer services or chatbots
Artificial intelligence in customer services or chatbots
 
Girls Call Jogeshwari 9967584737 Provide Best And Top Girl Service And No1 in...
Girls Call Jogeshwari 9967584737 Provide Best And Top Girl Service And No1 in...Girls Call Jogeshwari 9967584737 Provide Best And Top Girl Service And No1 in...
Girls Call Jogeshwari 9967584737 Provide Best And Top Girl Service And No1 in...
 
TEQnation 2024: Sustainable Software: May the Green Code Be with You
TEQnation 2024: Sustainable Software: May the Green Code Be with YouTEQnation 2024: Sustainable Software: May the Green Code Be with You
TEQnation 2024: Sustainable Software: May the Green Code Be with You
 
Authentication Review-June -2024 AP & TS.pptx
Authentication Review-June -2024 AP & TS.pptxAuthentication Review-June -2024 AP & TS.pptx
Authentication Review-June -2024 AP & TS.pptx
 
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
Agra Girls Call Agra 0X0000000X Unlimited Short Providing Girls Service Avail...
 
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdfA Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
A Step-by-Step Guide to Selecting the Right Automated Software Testing Tools.pdf
 
InflectraCON 360: Risk-Based Testing for Mission Critical Systems
InflectraCON 360: Risk-Based Testing for Mission Critical SystemsInflectraCON 360: Risk-Based Testing for Mission Critical Systems
InflectraCON 360: Risk-Based Testing for Mission Critical Systems
 
BATber53 AWS Modernize your applications with purpose-built AWS databases
BATber53 AWS Modernize your applications with purpose-built AWS databasesBATber53 AWS Modernize your applications with purpose-built AWS databases
BATber53 AWS Modernize your applications with purpose-built AWS databases
 
UMiami degree offer diploma Transcript
UMiami degree offer diploma TranscriptUMiami degree offer diploma Transcript
UMiami degree offer diploma Transcript
 
🚂🚘 Premium Girls Call Ranchi 🛵🚡000XX00000 💃 Choose Best And Top Girl Service...
🚂🚘 Premium Girls Call Ranchi  🛵🚡000XX00000 💃 Choose Best And Top Girl Service...🚂🚘 Premium Girls Call Ranchi  🛵🚡000XX00000 💃 Choose Best And Top Girl Service...
🚂🚘 Premium Girls Call Ranchi 🛵🚡000XX00000 💃 Choose Best And Top Girl Service...
 
Celebrity Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Servic...
Celebrity Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Servic...Celebrity Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Servic...
Celebrity Girls Call Mumbai 9920725232 Unlimited Short Providing Girls Servic...
 
AI - Your Startup Sidekick (Leveraging AI to Bootstrap a Lean Startup).pdf
AI - Your Startup Sidekick (Leveraging AI to Bootstrap a Lean Startup).pdfAI - Your Startup Sidekick (Leveraging AI to Bootstrap a Lean Startup).pdf
AI - Your Startup Sidekick (Leveraging AI to Bootstrap a Lean Startup).pdf
 
Il Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazioneIl Data Streaming per un’AI real-time di nuova generazione
Il Data Streaming per un’AI real-time di nuova generazione
 
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 …
 
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in CityGirls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
Girls Call Mysore 000XX00000 Provide Best And Top Girl Service And No1 in City
 
Amadeus Travel API, Amadeus Booking API, Amadeus GDS
Amadeus Travel API, Amadeus Booking API, Amadeus GDSAmadeus Travel API, Amadeus Booking API, Amadeus GDS
Amadeus Travel API, Amadeus Booking API, Amadeus GDS
 
AWS DevOps-Tutorial CHANAKYA SRIYAN DUKKA.
AWS DevOps-Tutorial CHANAKYA SRIYAN DUKKA.AWS DevOps-Tutorial CHANAKYA SRIYAN DUKKA.
AWS DevOps-Tutorial CHANAKYA SRIYAN DUKKA.
 

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