1

我想写 if condition with or conditions :

[% IF  bug.product == 'CustomerCare' or bug.product =='Alerts' or bug.product =='Chatlog' %]
<tr><td colspan="2">   <h3 align="center">Have you verified the Checklist ?</h3></td></tr>

<tr> 
    <td>  
        <input type="checkbox" id="chck1" name="greet" value="1" [% FOREACH gre =  chk_greet%] checked [% END%] /> 
    </td>

    <td> 
        <label for = "chck1">  Greet the customer ?</label> 
    </td>
</tr>

<tr>
    <td> <input type="checkbox" id="chck2" name="issue_status" value="1" [% FOREACH iss =  chk_issustat%] checked [% END%] /> 
    </td>
    <td> <label for = "chck2">Issue under concern and its status (whether resolved or not)</label> </td> 
</tr>

<tr> 
    <td> 
        <input type="checkbox" id="chck3" name="done_fix" value="1" [% FOREACH don = chk_done%] checked [% END%] [% END %]/> 
    </td> 
</tr> 

写这个条件的正确格式是什么?

4

2 回答 2

4

阅读精美的手册。它包括您的案例的示例。

[% IF (bug.product == 'CustomerCare') || (bug.product =='Alerts') ... %]
于 2013-05-26T09:41:10.013 回答
2

如果您的值列表开始变得有点大,使用 hashref 是另一种简化此逻辑的方法 - 特别是如果您最终要一遍又一遍地编写它。它还使逻辑更清晰,更简洁。

[%- # Do this once, near the top.
    SET checklistable = { CustomerCare => 1, Alerts => 1, Chatlog => 1 }; -%]

[%- # then later on, as required;
    IF checklistable.item(bug.product);
        ....
    END; -%]
于 2013-05-26T23:59:23.900 回答