Javascript 如何在sightly模板中写入条件?

Javascript 如何在sightly模板中写入条件?,javascript,adobe,aem,sightly,htl,Javascript,Adobe,Aem,Sightly,Htl,Sighly模板是否基于条件进行渲染 e、 g。 基于参数的component.html呈现 如果一个论点存在 <div data-sly-use.myComponent="${'com.myproject.service' @ param1='one''}"> ${myComponent.calculatedValue} </div> ${myComponent.calculatedValue} 如果论点二存在 <div data-sly-use.m

Sighly模板是否基于条件进行渲染

e、 g。 基于参数的component.html呈现

如果一个论点存在

<div data-sly-use.myComponent="${'com.myproject.service' @ param1='one''}">
    ${myComponent.calculatedValue}
</div>

${myComponent.calculatedValue}
如果论点二存在

<div data-sly-use.myComponent="${'com.myproject.service' @ param2='one''}"">
    ${myComponent.calculatedValue}
</div>

通过使用
数据sly测试,可以在HTL/Sightly中进行条件呈现(请参阅):

。。
..
..
这允许您基于参数实例化不同的使用对象。参数必须以内联方式定义,通过可用绑定/或其他使用对象访问


此时操作在HTL表达式中。

如何在数据行中传递这些值
<div data-sly-use.myComponent="${'com.myproject.MyComponent'}">
    ${myComponent.calculatedValue}
</div>
<div data-sly-test="${param1 == 'one'}"..>..</div>
<div data-sly-test="${param2 == 'one'}"..>..</div>
<div data-sly-test="${param1 != 'one' && param2 != 'one'}"..>..</div>