Re: [Dancer-users] Dancer qw(:script) - possible bug with template
"Nick Knutov" <mail@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@preshweb.co.uk> Sent from my phone so please excuse brevity / poor quoting style etc -- David Precious <davidp@preshweb.co.uk> Sent from my phone so please excuse brevity / poor quoting style etc
On Sun, 2011-07-03 at 11:50 +0100, David Precious wrote:
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.
I've raised this as Issue 592 to track it: https://github.com/sukria/Dancer/issues/592 -- David Precious ("bigpresh") http://www.preshweb.co.uk/ "Programming is like sex. One mistake and you have to support it for the rest of your life". (Michael Sinz)
On Sun, 2011-07-03 at 12:00 +0100, David Precious wrote:
I've raised this as Issue 592 to track it:
And I've pushed a fix in branch issue592: https://github.com/sukria/Dancer/commit/8fb2801aaa2b9138091e31720b4dd2549bf3... Nick, please feel free to test that against your code if you have a moment :) Other devs - please eyeball that and confirm you're happy with it. (I need to get my fork back up to date, otherwise I'd have done it as a pull request; it's a simple change, though, which should be perfectly safe.) -- David Precious ("bigpresh") http://www.preshweb.co.uk/ "Programming is like sex. One mistake and you have to support it for the rest of your life". (Michael Sinz)
Thanks, this patch works fine! 03.07.2011 17:07, David Precious пишет:
On Sun, 2011-07-03 at 12:00 +0100, David Precious wrote:
I've raised this as Issue 592 to track it:
And I've pushed a fix in branch issue592:
https://github.com/sukria/Dancer/commit/8fb2801aaa2b9138091e31720b4dd2549bf3...
Nick, please feel free to test that against your code if you have a moment :)
-- Best Regards, Nick Knutov http://knutov.com ICQ: 272873706 Voice: +7-904-84-23-130
On Sun, 2011-07-03 at 17:38 +0600, Nick Knutov wrote:
03.07.2011 17:07, David Precious пишет:
On Sun, 2011-07-03 at 12:00 +0100, David Precious wrote:
I've raised this as Issue 592 to track it:
And I've pushed a fix in branch issue592:
https://github.com/sukria/Dancer/commit/8fb2801aaa2b9138091e31720b4dd2549bf3...
Nick, please feel free to test that against your code if you have a moment :)
Thanks, this patch works fine!
Thanks for confirming it works for you! I've now merged this into devel; it'll be included in the next release. Thanks for reporting this issue and helping us to make Dancer better :) Cheers Dave P -- David Precious ("bigpresh") http://www.preshweb.co.uk/ "Programming is like sex. One mistake and you have to support it for the rest of your life". (Michael Sinz)
engine('template')->render
At the first look it's working solution, but it seems that I should add path to views to the template path. It looks like a bug too. 03.07.2011 16:50, David Precious пишет:
"Nick Knutov"<mail@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.
-- Best Regards, Nick Knutov http://knutov.com ICQ: 272873706 Voice: +7-904-84-23-130
participants (2)
-
David Precious -
Nick Knutov