New Features in AEM 6.1 Sightly

In this blog, I will explain new features introduced in AEM6.1 Sightly. These features will make your sightly code more shorter and simple. These features are listed below.

  1. Introduction of <sly> tag.
  2. data-sly-repeat
  3. URL manipulation
  4. local for i18n

I will explain these features in the form of questionnaires, so let’s start.

Q1). What is the use of <sly> tag?

This tag is used to remove extra divs those are generated when we include a resource in our component’s HTML file using Sightly code.

Q2). We can do that using data-sly-unwrap, why <sly>?

For explaining this, Let’s consider we have to include a parsys component in our HTML without extra divs using data-sly-unwrap then your code line will be-

It will work fine but in this case, you have to first define a <div> tag to use data-sly-resource attribute and you also have to write data-sly-unwrap to remove this extra <div> tag.
Isn’t it simple if you don’t have to write this extra <div> tag and data-sly-unwrap.

Q3). How to use <sly> tag? or what is the syntax of <sly> tag?

If you want to write the same line using <sly> tag then code will be-

Here, you can see the difference between old approach and <sly> tag.

Q4). will <sly> tag not generate any extra divs?

Yes, it will not generate any extra <div> tag or any HTML DOM element, you can think it as a replacement of data-sly-unwrap Sightly tag.

Q5). is data-sly-unwrap is deprecated or removed from AEM6.1 Sightly?

No, you can use it as well but as you have a much better <sly> tag then I think data-sly-unwrap is not required. I think, It is available only to support the AEM6.0 Sightly code.

Q6). What is the data-sly-repeat tag in Sightly?

This tag is used to iterate any of the list element.

Q7). Can we do that using data-sly-list in Sightly?

Yes, you can do that by using data-sly-list but the only difference is that, if you use data-sly-repeat, you will not have to provide any container element.

Q8). Not getting your point, could you please elaborate on your statement i.e. any container element?

Let us consider you want to iterate all child pages of currentPage object then first use data-sly-list you will write the code as –

Output will be generated as –

And when you view the HTML element structure in you debugger then it will be –

Now use data-sly-repeat

Output will be –

And when you view the HTML element structure in you debugger then it will be –

You can see these generated DOM elements in debugger’s Elements tab.

Q9). We can achieve same DOM structure using data-sly-list, is it required to use data-sly-repeat for the same?

No, it is not required but using data-sly-repeat your HTML code will become shorter. For ex. If you want to achieve

output then the code you have to write with data-sly-list will be –

Here you have to add data-sly-unwrap and <div> tag for each element. But by using data-sly-repeat, These tags will not be required and your HTML looks more refined, simple and less complex.

Q10). What is URL manipulation in AEM6.1 Sightly?

In AEM 6.1 you can do some URL manipulations which are not available in AEM6.0 Sightly. Some of the examples are –
Adding extension, code is –

Output will be –

Adding scheme (http or https) if required –

Output will be –

Adding Selectors –

Output will be –

Adding Fragments –

Output will be –

Q11). What is the locale for i18n?

This locale is newly introduced object in AEM6.1. When we work with i18n in Sightly we can use this object to set custom locale. It can be used as –

Note –  This object is not present in AEM6.

I am also sharing the Git repository link where you can find demo examples for these properties.
Git repository link is –

Happy Coding..!!

Ankur Chauhan
Tech Lead