[Dancer-users] bug with multiple "template" calls ?

Assaf Gordon gordon at cshl.edu
Thu Dec 15 21:02:17 CET 2011


More details:

Assaf Gordon wrote, On 12/15/2011 02:18 PM:
> Hello,
> 
> I have one (or more) calls to "template" to create the email text.
> and the last "template" creates the HTML page.
> 
> [...]
>
> With Dancer version 1.3079_3, it worked perfectly.
> After upgrading to 1.3090, the result of the first template is always returned to the user - what changed ? any ideas/suggestions are welcomed.
> 

It seems now that a call to "template" immediately terminates the route's handling code - no code is executed after calling template (it's not just "return" because it exits multiple function calls").

Example:
==============
sub foo
{
        print STDERR "foo - start\n";
        my $text = template("dummy", {} );
        print STDERR "foo - done\n";
}

sub bar
{
        print STDERR "bar - start\n";
        foo();
        print STDERR "bar - done\n";
}

get '/' => sub {
        print STDERR "before bar\n";
        bar();
        print STDERR "after bar\n";

        return template("index.tt", {} );
};
==================

prints "bar-start" and "foo-start" but never "foo-done" and "bar-done" .

Using "git bisect" (if I used it correctly), this is the first bad commit:
========
cfda458efb1e6458a25c57469d95cf25b2ec7f75 is the first bad commit
commit cfda458efb1e6458a25c57469d95cf25b2ec7f75
Author: Damien Krotkine <dams at cpan.org>
Date:   Fri Oct 7 11:32:07 2011 +0200

    pass, redirect, forward, halt, send_error, send_file, template now intterupt route workflows (no need to return)

:040000 040000 8911d9022331792a8a49c00d8eb758bb6d424f7c a958def44e6f1e764029d9bd27403a1b5cda3248 M	lib
:040000 040000 47f431b5e310a8870ced9665964088c621a900d8 d708491c4379283a9286f05862ef45b84a2772a1 M	t
========

(hehe, after reading the commit message, it's kind of obvious...) .


In any case - is this behavior going to be permanent ?
Meaning: "template" can only be used once, and must be the last statement ?
I can see why it makes sense for "pass", "direct", "send_error" etc. (and probably for most use cases of "template") - but there are exception, like in my case...

thanks,
 -gordon



More information about the Dancer-users mailing list