Skip to content

Permit use of modulo operator within HTL conditionals #94

@james-appleby

Description

@james-appleby

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions