Please have a look at this post,
Link:- http://stackoverflow.com/questions/28571842/display-different-markup-in-sightly-based-on-a-sling-sel...
//Display different markup in HTML Template Language (HTL formerly known as Sightly) based on a Sling selector
Also Refer to the documentation here :-
Link:- https://docs.adobe.com/docs/en/htl/docs/block-statements.html (Search for Selector)
//
Add (or replace) a selector:
<article data-sly-resource="${'path/to/resource' @ selectors='selector'}"></article>
Code samples are intended for illustration purposes only.
Add, replace or remove multiple selectors:
<article data-sly-resource="${'path/to/resource' @ selectors=['s1', 's2']}"></article>
Code samples are intended for illustration purposes only.
Add a selector to the existing ones:
<article data-sly-resource="${'path/to/resource' @ addSelectors='selector'}"></article>
Code samples are intended for illustration purposes only.
Remove some selectors from the existing ones:
<article data-sly-resource="${'path/to/resource' @ removeSelectors='selector1'}"></article>
Code samples are intended for illustration purposes only.
Remove all selectors:
<article data-sly-resource="${'path/to/resource' @ removeSelectors}"></article>
I hope this would help you.
Thanks and Regards
Kautuk Sahni
Kautuk Sahni