[dancer-users] Delayed template processing

John McDermott, CPLP jjm at jkintl.com
Fri Oct 16 01:11:29 BST 2015


The first sentence should have been:
It seems as though since "done" closes the connection, you can't expect 
Dancer2 to keep sending data there.

On 10/15/2015 3:16 PM, John J. McDermott, CPLP wrote:
> It seems as though since "done" closes the connection. The doc says 
> "If you are streaming (calling |content| several times), you must call 
> |flush| ". I think it needs to be higher in the delayed block.
>
> I'm not sure how you'd tell routeB to use the current (hopefully open) 
> template, and just to keep sending.
>
> See 
> http://search.cpan.org/~xsawyerx/Dancer2-0.163000/lib/Dancer2/Manual.pod#Delayed_responses_%28Async/Streaming%29
>
> --john
>
>
> On 10/15/2015 12:10 PM, Joerg Fallmann wrote:
>> Hi again,
>> Does anybody know if and how it is possible
>> to render a template for the user and
>> then forward to a new route,
>>
>> Something like
>>
>> |get '/routeA/:*?' => 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 }; flush; content $tt; done; }; forward '/routeB/',{ |
>> ||'id' => $id, 'bla' => $blub| }; }; ||get '/routeB/:*?' => sub { my $id = params->{'id'}; my $blub = 
>> params->{'bla'}; # Do something from here on }; |
>> That would solve the async response troubles for me I guess.
>>
>> @John, I'd rather try to do as much as possible without having to 
>> handle JSON additionally,
>> if async streaming is possible the way I like to use it, I will have 
>> no other choice anyway I guess.
>>
>> --joerg
>>
>>
>>
>>
>> _______________________________________________
>> dancer-users mailing list
>> dancer-users at dancer.pm
>> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
> -- ___ 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/20151015/f607dd4c/attachment.html>


More information about the dancer-users mailing list