[Dancer-users] Dancer qw(:script) - possible bug with template

David Precious davidp at preshweb.co.uk
Sun Jul 3 12:50:28 CEST 2011



"Nick Knutov" <mail at knutov.com> wrote:

>use Dancer qw(:script);
>use myapp;
>[...]
>my $report = template '...', {foo=>'bar'}, {layout=>''};
>
>Can't call method "params" on an undefined value at 
>/usr/local/share/perl/5.10.1/Dancer/Template/Abstract.pm line 112.
>
>Is it a bug? Or what I'm doing wrong?

Looks like template() expects to be called within a route handler where there's a request being processed, but you're using it outside of routes in a simple script. 

It should be possible to amend template() to check if there's a request and if not, skip adding params as a token - I'll take a look soon. 

In the meantime you may be able to call e.g. engine('template')->render or similar. 

-- 
David Precious <davidp at preshweb.co.uk>
Sent from my phone so please excuse brevity / poor quoting style etc

-- 
David Precious <davidp at preshweb.co.uk>
Sent from my phone so please excuse brevity / poor quoting style etc


More information about the Dancer-users mailing list