[英]How to compare two strings in Sightly/HTL? (AEM 6.2)
我创建了一个简单的下拉列表,其中包含两个选项 Yes 和 No,它们分别返回“true”和“false”的值。
<enableTool
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/select"
class="cq-dialog-dropdown-showhide"
cq-dialog-dropdown-showhide-target=".list-option-listfrom-showhide-target"
fieldLabel="Enable tooltip?"
name="./enableTool">
<items jcr:primaryType="nt:unstructured">
<true
jcr:primaryType="nt:unstructured"
text="Yes"
value="true"/>
<false
jcr:primaryType="nt:unstructured"
text="No"
value="false"/>
</items>
</enableTool>
我想直观地实现以下逻辑
if (value of the returned string is true)
{
Do something
}
对于这是写了以下粗略的代码
<div data-sly-test="${properties.enableTool == 'true'}"> Value is true</div>
当我运行此“值为真”时,无论propeties.enableTool 的值是真还是假,始终都会打印。
请注意,如果我写<div> ${properties.enableTool} </div>
,我会根据我的选择正确地将值视为 true 或 false 。
知道我做错了什么吗?
提前致谢!
我相信HTL 条件三元运算符就是您要寻找的。
<p>${properties.enableTool ? "tool is enabled" : "tool is disabled"}</p>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.