2013-05-26 6 views
1

의 루프 내가 쓰고 싶은 경우에 컨디셔닝하고 싶은 조건 조건 또는 경우 :는 쓰기 나 펄 템플릿 도구 키트

[% 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> 

이 조건을 작성하는 올바른 형식은 무엇입니까?

+0

사이에 넣을 수 있습니까? 그게 올바른 방법입니까? –

답변

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; -%] 
4

the fine manual을 읽으십시오. 그것은 당신의 사건에 대한 예를 포함합니다. 값 귀하의 목록은 조금 큰 얻을 시작하면

[% IF (bug.product == 'CustomerCare') || (bug.product =='Alerts') ... %] 
+1

감사합니다 ...... :) –