Hi,
i'm using HTML::Template with the
$tpl->output(print_to => *SOMETHING)-syntax with mod_perl,
because i wanted to print the results while the template is parsed, but
while i developed my stuff, i encountered a problem with print_to.
When parsing LOOPs, HTML::Template parses the whole loop, and returns
everything parsed, to the normal output-routine, this isn't useful if
you have a BIG loop, such me (more than 1500 entries), because the
print_to-feature will not work in this case, until the loop returns.
So i did a little patch against HTML::Template 2.5
The patch:
--- HTML-Template-2.5/Template.pm Sat Feb 2 00:01:37 2002
+++ /usr/lib/perl5/site_perl/5.6.1/HTML/Template.pm Tue May 14
15:47:07 2002
@@ -2508,7 +2508,7 @@
defined($$line) and $result .= $$line;
} elsif ($type eq 'HTML::Template::LOOP') {
if (defined($line->[HTML::Template::LOOP::PARAM_SET])) {
- eval { $result .= $line->output($x,
$options->{loop_context_vars}); };
+ eval { $line->output($x,
$options->{loop_context_vars},\$result); };
croak("HTML::Template->output() : fatal error in loop output :
$@")
if $@;
}
@@ -2768,11 +2768,11 @@
my $self = shift;
my $index = shift;
my $loop_context_vars = shift;
+ my $result_ref = shift;
my $template = $self->[TEMPLATE_HASH]{$index};
my $value_sets_array = $self->[PARAM_SET];
return unless defined($value_sets_array);
- my $result = '';
my $count = 0;
my $odd = 0;
foreach my $value_set (@$value_sets_array) {
@@ -2787,14 +2787,14 @@
$odd = $value_set->{__odd__} = not $odd;
}
$template->param($value_set);
- $result .= $template->output;
+ $$result_ref .= $template->output;
$template->clear_params;
@{$value_set}{qw(__first__ __last__ __inner__ __odd__)} = (0,0,0,0)
if ($loop_context_vars);
$count++;
}
- return $result;
+# return $result;
}
package HTML::Template::COND;
-----------------------------------------------------------
It doesn't changes much, it just gives the Loop-routine a reference to
the $result-string, and the loop uses this one.
I haven't tested it very much, because i had no time, but maybe someone
finds it useful.
ciao Nico
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]