如何比较Sightly/HTL中的两个字符串?(AEM 6.2)

如何比较Sightly/HTL中的两个字符串?(AEM 6.2),aem,sightly,htl,Aem,Sightly,Htl,我创建了一个简单的下拉列表,其中有两个选项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-l

我创建了一个简单的下拉列表,其中有两个选项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>
为此,编写了以下代码

<div data-sly-test="${properties.enableTool == 'true'}"> Value is true</div>
值为true
当我运行时,无论properties.enableTool的值是真还是假,始终打印“Value is true”

请注意,如果我写
${properties.enableTool}
,我会根据我的选择正确地看到值为true或false

知道我做错了什么吗

提前谢谢

我相信这就是你要找的

<p>${properties.enableTool ? "tool is enabled" : "tool is disabled"}</p>
${properties.enableTool?“工具已启用”:“工具已禁用”}


我认为您的代码没有问题。它应该很好用。为了更好地调试,请添加更多与dialog和HTL文件相关的代码。我用提供的代码创建了一个字段,并使用相同的Sighly代码检查测试条件,它对我来说运行良好,我使用的Sighly代码:Value is true Value is False与上面的两条注释类似,我没有看到代码中的问题,您使用的是什么版本的AEM?此外,我建议您使用HTL REPL进行快速HTL测试:
<p>${properties.enableTool ? "tool is enabled" : "tool is disabled"}</p>