[英]How to set the variable value to the resource selectors?
I need to set the selector using data-sly-resource.我需要使用 data-sly-resource 设置选择器。 It works if I set the selector name directly.
如果我直接设置选择器名称,它会起作用。 But I need to pass the selector name which is saved in variable.
但我需要传递保存在变量中的选择器名称。 How to set the value of "selector" variable ("settings1" or "settings2") to the selectors of data-sly-resource?
如何将“selector”变量(“settings1”或“settings2”)的值设置为data-sly-resource的选择器?
<template data-sly-template.edit="${ @ settings }">
<div data-sly-test.selector="${settings == 'data' ? 'settings1' : 'settings2'}">
<div data-sly-resource="${ @path='home', resourceType='/aem/test/components/component', selectors='${selector}' }"></div>
</div>
</template>
This code doesn't work...此代码不起作用...
You can pass HTL variables directly to the expression options:您可以将 HTL 变量直接传递给表达式选项:
data-sly-resource="${ @path='home', resourceType='/aem/test/components/component', selectors=selector }"
BTW, instead of data-sly-test
you could use data-sly-set
to assign the value for selector
.顺便说一句,您可以使用
data-sly-set
为selector
分配值,而不是data-sly-test
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.