Re: [Templates] SELECT CASE question
[prev]
[thread]
[next]
[Date index for 2004/11/30]
>>>>> "Robert" == Robert <sigzero@xxxxx.xxx> writes:
Robert> Currently I have an IF/ELSE block that determines if the loop.count is
Robert> divisible by 2 and it sets the background color.
Robert> [% IF (loop.count % 2) %]
Robert> <tr id="trcol1">
Robert> <td>[% report.DSTRCT_CODE %]</td>
Robert> <td>[% report.WORK_ORDER %]</td>
Robert> <td>[% report.CREATION_DATE %]</td>
Robert> <td>[% report.LAST_MOD_DATE %]</td>
Robert> <td>[% report.ORIGINATOR_ID %]</td>
Robert> <td>[% report.SURNAME %]</td>
Robert> <td>[% report.FIRST_NAME %]</td>
Robert> </tr>
Robert> [% ELSE %]
Robert> <tr id="trcol2">
Robert> <td>[% report.DSTRCT_CODE %]</td>
Robert> <td>[% report.WORK_ORDER %]</td>
Robert> <td>[% report.CREATION_DATE %]</td>
Robert> <td>[% report.LAST_MOD_DATE %]</td>
Robert> <td>[% report.ORIGINATOR_ID %]</td>
Robert> <td>[% report.SURNAME %]</td>
Robert> <td>[% report.FIRST_NAME %]</td>
Robert> </tr>
Robert> [% END %]
I stared at that about ten times to make sure those names were the
same. Since they are, why didn't you just do this?
<tr id="trcol[% IF loop.count % 2; "1"; ELSE; "2"; END %]">
<td>[% report.DSTRCT_CODE %]</td>
<td>[% report.WORK_ORDER %]</td>
<td>[% report.CREATION_DATE %]</td>
<td>[% report.LAST_MOD_DATE %]</td>
<td>[% report.ORIGINATOR_ID %]</td>
<td>[% report.SURNAME %]</td>
<td>[% report.FIRST_NAME %]</td>
</tr>
Much easier to maintain!
The point of a template is to write the things once, and vary the parts
that vary. Cut-n-paste is evil, Evil, EVIL!
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@xxxxxxxxxx.xxx> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates
 |
 |
Re: [Templates] SELECT CASE question
merlyn (Randal L. Schwartz) 14:34 on 30 Nov 2004
|