Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permit use of modulo operator within HTL conditionals #94

Open
james-appleby opened this issue Aug 23, 2021 · 0 comments
Open

Permit use of modulo operator within HTL conditionals #94

james-appleby opened this issue Aug 23, 2021 · 0 comments

Comments

@james-appleby
Copy link

james-appleby commented Aug 23, 2021

The restriction to only allow logical and comparative operators in HTL means modulus operations can't be performed.

<ul data-sly-test="${ model.items.size > 0 }" data-sly-list.item="${ model.items }">
    <sly data-sly-resource="${ item @ decorationTagName='li' }"></sly>
    <sly data-sly-test="${itemList.count % 5 ==0}"> ... </sly>    
</ul>

As well as using a constant ("5" in the example above) it should also be possible to use a HTL variable declared before the list or the result of a call into a Java model method, provided the value can be cast to an Integer.

While this does allow very limited business logic into the HTL layer, it's hard to see any other way of implementing a requirement within the list feature. This has been discussed in the past by other users here: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/can-we-use-modulo-in-sightly/td-p/260156

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant