I'm looking into adding support for incremental output to the Template 
Toolkit, since outputting processed content incrementally rather than 
all-at-once can increase perceived performance in some situations (for 
example with output from a CGI request).

The approach I am taking is to add a method to Context.pm for sending 
processed content to the output stream and then call that method in 
compiled templates for each chunk of generated content rather than 
saving it all up and sending it at the end.  I'm also adding an 
"INCREMENTAL" configuration variable that enables this functionality 
(disabled by default).

The wall I have run into is trying to figure out how to distinguish 
between content within a template being processed (whose content could 
be output incrementally) and content within a block (or filter or macro) 
within that template, whose generated content should be stored until the 
value of that block gets inserted into the template.

For example, if incremental output is enabled, some calls to 
Template::Directive::text should output:

$context->output("the text");

But those within a block should still output:

$output .= "the text";

Where and how do I make this distinction?

-myk




Reply via email to