in reply to Template Toolkit, and delaying the execution of a function
sub show_elements ($)
{
my $num = $_[0];
return [] unless( $num > 0 );
return [ 1..$num ];
}
...
my $data = {
show_elements => show_elements( $elements ),
};
then in the template:
<ul>
{# FOREACH e = show_elements #}
<li>{# e #}</li>
{# END #}
</ul>
If you really need to delay the sub call, have a look at the TT docs which explain it quite adequately.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(elbie 2): Template Toolkit, and delaying the execution of a function
by elbie (Curate) on Aug 18, 2001 at 18:38 UTC |