[dancer-users] Delayed template processing
Amelia Ireland
aireland at lbl.gov
Tue Oct 13 20:29:15 BST 2015
I'd like to do the same thing. I haven't yet been able to identify at which
point the streaming is failing (the browser? Apache proxy? Twiggy?
Dancer?), and have been waiting to see if any of the Dancer2 team will
explain things further.
In case it is helpful, there is some more information on PSGI and streaming
in the Catalyst advent calendar here:
http://www.catalystframework.org/calendar/2013/10 (four part series)
and the PSGI FAQ has some information on streaming:
https://metacpan.org/pod/PSGI::FAQ#What-if-I-want-to-stream-content-or-do-a-long-poll-Comet
I haven't had a chance to do much research lately, but my next steps will
be to find some other streaming PSGI apps to test (e.g. written with simple
Plack, or some Catalyst or Mojolicious apps), to try to track down whether
what we want to do is possible or whether the terminology is misleading.
On 13 October 2015 at 06:51, Joerg Fallmann <fall at tbi.univie.ac.at> wrote:
> Hi Everyone,
>
> What I'm looking for is a way to render a template with part of the
> results to the user to see while I continue processing and when I'm done I
> want to show the final template with all results. I'm currently using the
> new delayed method, which works fine for strings,
> but if I want to render templates it does not provide content until the
> very end, so no in-between output is produced, as I would like to show.
> Example code here:
>
> get '/test/:*?' => sub {
> my $id = params->{'id'};
> my $blub = params->{'blub'};
> delayed {
> my $tt = Template->new(
> {INCLUDE_PATH => "$path",
> WRAPPER => 'layout.tt',
> RELATIVE => 1,
> }) || die "Template error: $Template::ERROR\n";
> $tt->process('view.tt', {
> 'id' => $id,
> 'bla' => $blub
> };
> content $tt;
>
> ### Process further
> push my @more, "String";
> my $tt2 = Template->new(
> {INCLUDE_PATH => "$path",
> WRAPPER => 'layout.tt',
> RELATIVE => 1,
> }) || die "Template error: $Template::ERROR\n";
> $tt2->process('view.tt', {
> 'id' => $id,
> 'bla' => $blub,
> 'more' => \@more
> };
> content $tt2;
> done;
> };
> };
>
> Is this possible or am I completely on the wrong track?
> Thanks,
> Joerg
>
> Phone: +43 1 4277 52732
>
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20151013/7566ee84/attachment.html>
More information about the dancer-users
mailing list