Kelly, Actually, the output is not a webpage. Imagine for a second that the output is an LED sign and, say, I'm trying to output a countdown clock that goes "10", "9", "8", etc. and sleeps one second between each second. What I don't want is 10 seconds of nothing, then suddenly $output being "10 9 8 7 6 5 4 3 2 1 0". I want to receive the "10", then it will wait 1 second, then send me the "9", then wait one second, etc. I could do that with a "WRITE" command where anything destined to go to the LED sign is sent through that, which would work in real-time, but my question is whether that could be done by overriding the normal standard output method so I wouldn't have to re-do thousands of templates. --drew
_____ From: Kelly Thompson [mailto:[EMAIL PROTECTED] Sent: Saturday, December 08, 2007 8:44 PM To: Drew Hahn Subject: Re: [Templates] Streaming template output versus waiting for entire parse Look into Template Toolkit and Mod_perl.... That's way quicker! And, Andy made it readily available. On Dec 8, 2007 2:59 PM, Drew Hahn <HYPERLINK "mailto:[EMAIL PROTECTED]" [EMAIL PROTECTED]> wrote: Is there a way for the output of a template to be _streamed_ out as it is processed versus waiting for it to complete before returning? I know I could do it with something like this below, as a result of the WRITE command in the example, but I'm looking for a way to do this without having to re-write all of my existing templates which simply write to standard out as usual. I'm fine with a strategically-placed hack, which is what I'm working on now, but any other ideas (or a pointer to the appropriate section of code) would be helpful. Thanks! my %data = ( SLEEP => sub { sleep(2); }, WRITE => sub { print shift() . "\n"; }, ); my $sample =<<EOM; [% x = 0 %] [% WHILE x < 5 %] [% WRITE('This is ' _ x) %] [% SLEEP %] [% x = x + 1 %] [% END %] EOM my $template = Template->new({ OUTPUT => \&showOutput, }); $template->process(\$sample, \%data) || die $template->error(); sub showOutput { print shift(); } --drew No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.503 / Virus Database: 269.16.17/1177 - Release Date: 12/7/2007 1:11 PM _______________________________________________ templates mailing list HYPERLINK "mailto:[email protected]"[email protected] HYPERLINK "http://mail.template-toolkit.org/mailman/listinfo/templates" \nhttp://mail.template-toolkit.org/mailman/listinfo/templates No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.503 / Virus Database: 269.16.17/1177 - Release Date: 12/7/2007 1:11 PM No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.503 / Virus Database: 269.16.17/1178 - Release Date: 12/8/2007 11:59 AM
_______________________________________________ templates mailing list [email protected] http://mail.template-toolkit.org/mailman/listinfo/templates
