Skip to main content
cnur24357457
Level 2
Sep 19, 2017 12:08 AM UTC
Solved

Can we use % (modulo) in Sightly

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.

kautuk_sahni
kautuk_sahniAccepted solution
Level 9
Sep 19, 2017 5:27 AM UTC

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

8 replies

kautuk_sahni
kautuk_sahniAccepted solution
Level 9
Sep 19, 2017 5:27 AM UTC

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

Translate
Kautuk Sahni
Feike_Visser1
Adobe Employee
Adobe Employee
Sep 19, 2017 5:30 AM UTC

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?

Translate
cnur24357457
Level 2
Sep 19, 2017 11:31 AM UTC

Thanks kautuksahni & Feike Visser​

​Will raise sling ticket for the same.

Translate
Feike_Visser1
Adobe Employee
Adobe Employee
Sep 19, 2017 6:20 PM UTC

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

Translate
Ben_Cherian
Jan 11, 2019 9:13 PM UTC

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.

Translate
Feike_Visser1
Adobe Employee
Adobe Employee
Jan 12, 2019 9:00 AM UTC

Raise a sling jira-ticket for it.

Translate
Level 4
Oct 25, 2024 7:04 AM UTC

@feike_visser1 Any updates on this ticket?

Translate