The purpose of HTML Template Language (HTL), supported by Adobe Experience Manager (AEM), is to offer a highly productive enterprise-level web framework that increases security, and allows HTML developers without Java knowledge to better participate in AEM projects.
The HTML Template Language has been introduced with AEM 6.0, and takes the place of JSP (JavaServer Pages) as the preferred and recommended server-side template system for HTML. For web developers who need to build robust enterprise websites, the HTML Template Language helps to achieve increased security and development efficiency.
Note: For more on sightly watch this video
The HTML Template Language has been introduced with AEM 6.0, and takes the place of JSP (JavaServer Pages) as the preferred and recommended server-side template system for HTML. Folowing are the benefits of HTML Template Language
Increased Security - The HTML Template Language increases the security of sites that use it in their implementation, as compared to JSP and to most other template systems, because HTL is capable of automatically applying the proper context-aware escaping to all variables being output to the presentation layer. HTL makes this possible because it understands the HTML syntax, and uses that knowledge to adjust the required escaping for expressions, based on their position in the markup. This will for instance result in expressions placed in href or src attributes to be escaped differently from expressions placed in other attributes, or elsewhere.
While the same result can be achieved with template languages like JSP, there the developer must manually ensure that the proper escaping is applied to each variable. As a single omission or mistake on the applied escaping is potentially sufficient to cause a cross-site scripting (XSS) vulnerability, we decided to automate this task with HTL.
Java Use-API - The HTML Template Language (HTL) Java Use-API enables a HTL file to access helper methods in a custom Java class. This allows all complex business logic to be encapsulated in the Java code, while the HTL code deals only with direct markup production. Read more
JavaScript Use-API - The HTML Template Langugae (HTL) JavaScript Use-API enables a HTL file to access helper code written in JavaScript. This allows all complex business logic to be encapsulated in the JavaScript code, while the HTL code deals only with direct markup production. Read more
Without having to specify anything, HTL provides access to all objects that were commonly available in JSP after including global.jsp. These objects are in addition to any that may be introduced through the Use-API.
These objects provide convenient access to commonly used information. Their content can be accessed with the dot notation, and they can be iterated-through using data-sly-list or data-sly-repeat.
Variable Name | Description |
---|---|
properties | List of properties of the current Resource. Backed by org.apache.sling.api.resource.ValueMap |
pageProperties | List of page properties of the current Page. Backed by org.apache.sling.api.resource.ValueMap |
inheritedPageProperties | List of inherited page properties of the current Page. Backed by org.apache.sling.api.resource.ValueMap |
Variable Name | Description |
---|---|
component | com.day.cq.wcm.api.components.Component |
currentDesign | com.day.cq.wcm.api.designer.Design |
currentPage | com.day.cq.wcm.api.Page |
request | org.apache.sling.api.SlingHttpServletRequest |
resource | org.apache.sling.api.resource.Resource |
resourceDesign | com.day.cq.wcm.api.designer.Design |
resourcePage | com.day.cq.wcm.api.Page |
wcmmode | com.adobe.cq.sightly.SightlyWCMMode |
Sightly Offers below advantages over JSP for better development in AEM