Can we use % (modulo) in Sightly | Community
Skip to main content
cnur24357457
Level 2
September 19, 2017
Solved

Can we use % (modulo) in Sightly

  • September 19, 2017
  • 6 replies
  • 5808 views

Can we use %(modulo) in Sightly

I want to use below condition in sightly, how can I use it

<ul data-sly-list="${properties.size}">

<li  data-sly-test="${itemList.count % 3 ==0}"> Test </li>

</ul>

I know above code don't work. How to achieve above condition in sightly.

Best answer by kautuk_sahni

HTL (formerly known as Sightly ) only supports logical and comparison operators. It is intended as the view rendering scripts are not supposed to contain business logic, this should come from the model/use-objects/Js use-api.

Spec:- htl-spec/SPECIFICATION.md at master · Adobe-Marketing-Cloud/htl-spec · GitHub

Js Use-API: HTL JavaScript Use-API

Feike Visser Please correct me if I am wrong here.

~kautuk

6 replies

kautuk_sahni
Community Manager
kautuk_sahniCommunity ManagerAccepted solution
Community Manager
September 19, 2017

HTL (formerly known as Sightly ) only supports logical and comparison operators. It is intended as the view rendering scripts are not supposed to contain business logic, this should come from the model/use-objects/Js use-api.

Spec:- htl-spec/SPECIFICATION.md at master · Adobe-Marketing-Cloud/htl-spec · GitHub

Js Use-API: HTL JavaScript Use-API

Feike Visser Please correct me if I am wrong here.

~kautuk

Kautuk Sahni
Feike_Visser1
Adobe Employee
Adobe Employee
September 19, 2017

No %-modulo can't be used. However it is a great improvement to HTL/Sightly.

Would you mind to raise a sling-ticket on this?

cnur24357457
Level 2
September 19, 2017

Thanks kautuksahni & Feike Visser

​Will raise sling ticket for the same.

Feike_Visser1
Adobe Employee
Adobe Employee
September 19, 2017

Let me know the ticket, so I can help to expedite it.

Ben_Cherian
January 11, 2019

Would be great to have this functionality. If i need to render a list, and do something specific for every 5th element, ${itemList.index % 5 == 0} would be very useful.

Feike_Visser1
Adobe Employee
Adobe Employee
January 12, 2019

Raise a sling jira-ticket for it.

Level 3
October 25, 2024

@feike_visser1 Any updates on this ticket?