Article updated on July 27, 2016.

Welcome to part 3 of the introduction to the HTML Template Language (HTL), formerly known as Sightly. In this part I want to give you some more use-cases and examples that you can use in your components.

Interested in the others parts? Here they are: part 1, part 2, part 4, part 5.

HTL Arrays

Here a sample around arrays:

<!--/* Accessing a value */-->

<!--/* Printing an array */-->

<!--/* Printing the array, separating items by ; */-->
${aemComponent.names @ join=';'}

<!--/* Dynamically accessing values */-->
<ul data-sly-list="${aemComponent.names}">
    <li>${ properties[item]}</li>

HTL Comparisons

Here some use-cases on comparing values

<div data-sly-test="${properties.jcr:title == 'test'}">TEST</div>
<div data-sly-test="${properties.jcr:title != 'test'}">NOT TEST</div>

<div data-sly-test="${properties['jcr:title'].length > 3}">Title is longer than 3</div>
<div data-sly-test="${properties['jcr:title'].length >= 0}">Title is longer or equal to zero </div> 

<div data-sly-test="${properties['jcr:title'].length > aemComponent.MAX_LENGTH}">
    Title is longer than the limit of ${aemComponent.MAX_LENGTH}


In my second article I explained that you can call methods from your custom-classes via the data-sly-use notation.
In this example I will show that you can also pass in parameters from your components.

<div data-sly-use.aemComponent="${'com.myproject.components.MyComponent' @ firstName='feike', lastName='visser'}">

Java-code in the Use-API:

import com.adobe.cq.sightly.WCMUsePojo;
public class MyComponent extends WCMUsePojo {
    // firstName and lastName are available via Bindings 
    public String getFullname() {
        return get("firstName", String.class) + " " + get("lastName", String.class);

In the example above you define your parameters in the Use-API, and you are not restricted to a type.
Via the get() method that is available via the WCMUsePojo class, you can get the value of a binding.

I hope you enjoyed this part, more parts to come 🙂



Here are the other articles of my introduction series:

Other posts on the topic:

And here other resources to learn more about it:


Unable to navigate to part 1 & 2 posts of this series.