[Catalyst] unbuffered output via multiple templates

Todd Harris henri.segalat at gmail.com
Fri Aug 31 02:22:38 GMT 2007


Hi all -

Quick introduction:  I'm new to Catalys, but I've been reading the
mailing list online for some time.  I finally have a suitable project
and have just started working on it.  The documentation on list so far
have been a great help.

My question:  I'd like to unbuffer output a la $|++.  I thought one
approach might be to have a series of templates per page, rendering
each sequentially, delivering each to the client in turn.

So far I've come across two possible solutions: 1. SubRequest and 2.
View::TT->render.

But it seems that trapping the output of either and writing to STDOUT
closes the request, such that only the first template is rendered and
sent to the browser.

Some pseudo code to illustrate:

sub myaction : Local {
  my $something = $c->subreq('/do_something',{ bar => $c->stash->{bar} });
  $c->res->body($text);
  $c->res->write($text);

  my $else = $c->subreq('/do_something_else',{ foo => $c->stash->{foo} });
  $c->res->body($else);
  $c->res->write($else);
}

sub do_something : Local {
   my ($self,$c) = @_;
   $c->stash->{load_em_up} = 'here we go';
}

Am I completely off track here?  I've used a monolithic template with
lots of includes but that is not exactly what I would like to
accomplish here.

Thanks in advance for suggestions.

Henri



More information about the Catalyst mailing list