in reply to Simplifying repetitive flow structures
Then all you have to do is create an LoH (list of hashes) that has your data plus TYPE_C and TYPE_OTHER set and use it like:<TMPL_LOOP PHONEBOOK> <tr> <td> <TMPL_IF PIC> <TMPL_IF TYPE_OTHER> <img src="/images/thumb_<TMPL_VAR NAME=PIC>" </TMPL_IF> <a href="<TMPL_VAR NAME=PIC"><TMPL_VAR NAME=NAME></a> <TMPL_ELSE> <TMPL_VAR NAME=NAME> </TMPL_IF> </td> <td><TMPL_VAR NAME=PHONE></td> <td><TMPL_VAR NAME=FAX></td> <td><TMPL_VAR NAME=LOC></td> <td> <TMPL_IF TYPE_C> <TMPL_VAR NAME=CON> <TMPL_ELSE> <a href="mailto:<TMPL_VAR NAME=EMAIL>"><TMPL_VAR NAME=EMAI +L></a> </TMPL_IF> </td> </tr> </TMPL_LOOP>
This has the advantage of seperating out your code and design and allowing somebody else to tweak the output. For more info on HTML::Template see its documentation or using CGI, DBI and HTML::Template (a mini tutorial with example code).my $t = HTML::Template->new; $t->param(PHONEBOOK => \@data); print $t->output;
Hope this helps.
gav^
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Simplifying repetitive flow structures
by Dogma (Pilgrim) on Apr 01, 2002 at 03:21 UTC | |
by gav^ (Curate) on Apr 01, 2002 at 04:47 UTC | |
by jbisbee (Pilgrim) on Apr 01, 2002 at 14:19 UTC |