有没有办法在AEM中生成一个唯一的资源名?

问题描述 投票:0回答:1

我已经创建了一个表,在tbody里面有一个列表。它将生成一些行。但是,我必须使 resource name 每一行都是独一无二的。有什么想法吗?

    <table>
            <thead>
                <tr>
                    <td></td>
                </tr>
            </thead>
            <tbody data-sly-list="${itemCount}">
                <tr>
                    <td>
                        <div data-sly-resource="${'resourceName' @ resourceType='components/content/mycomponent'}"></div>
                    </td>
                </tr>
            </tbody>
        </table>
model osgi sling sightly aem-6
1个回答
1
投票

我不知道你打算怎么做。似乎你想生成唯一的合成资源名。

为此,你可以使用 itemList.countitemList.index 的值,如。res1, res2 ...或 res0, res1 ... 查看 HTL规范中的细节.

你可能必须使用 data-sly-set 将数字与文本连接起来。

        <tbody data-sly-list="${itemCount}">
            <tr>
                <td data-sly-set.resourceName="res${itemList.count}">
                    <div data-sly-resource="${resourceName @ resourceType='components/content/mycomponent'}"></div>
                </td>
            </tr>
        </tbody>
© www.soinside.com 2019 - 2024. All rights reserved.