I have my own fork of Dancer::Template::Ctpp2, which already does (b)
clause (and it works fine with 1.3072 and earlier). So the question is
more about breaking backward compatibility, which is, unfortunately,
occurs in all last releases.
I will try to cleanup code in my version of Dancer::Template::Ctpp2 and
upload it to github this night.
12.2011 0:21, David Precious пишет:
On Tue, 27 Dec 2011 04:01:04 +0600
Nick Knutov<[email protected]> wrote:
Hi all,
I have strange bug and no ideas what to do with it.
Template engine: ctpp
my $mail = template 'mails/ticket_new.txt', $data, {layout=>undef};
[3150] error @5.768842> [hit #1]Supplied view (mails/ticket_new.txt)
was not found.
in /usr/local/share/perl/5.10.1/Dancer/Template/Abstract.pm l. 167
[3150] error @6.503130> [hit #1]request to /reg/ crashed:
Dancer::Response=HASH(0xb3f0718) in
/usr/local/share/perl/5.10.1/Dancer/Handler.pm l. 98
kola@vbox:path/to/app/views$ ls -l mails/ticket_new.txt
-rw-r--r-- 1 kola kola 339 2011-08-19 19:47 mails/ticket_new.txt
Looking at the relevant code in Dancer::Template::Abstract :
if ($view) {
# check if the requested view exists
my $view_path = $engine->view($view);
if (-e $view_path) {
$content = $engine->apply_renderer($view, $tokens);
} else {
Dancer::Logger::error("Supplied view ($view) was not
found.");
Since it's checking whether $view_path exists, it should really use
$view_path in the error message, not $view.
If it did, the problem would become more apparent - the view() method
appends the default template extension if the view name supplied
doesn't already end in it.
Dancer::Template::Ctpp2->default_tmpl_ext() will return 'ct2' if the
use_bytecode option is enabled, or 'tmpl' otherwise.
So, Dancer is looking for mails/ticket_new.txt.tmpl, not
mails/ticket_new.txt - but unfortunately, that error message is not
clear as to why.
I think there are two fixes here:
(a) make the error message clearer, so it's obvious what's going on;
(b) check for a view matching the exact name supplied first, before
attempting to add the default template extension; I think this would be
the most appropriate behaviour.
So, for the time being, renaming the template will make things work,
and I'll fix this oversight shortly - thanks for reporting it!
Cheers
Dave P
--
Best Regards,
Nick Knutov
http://knutov.com
ICQ: 272873706
Voice: +7-904-84-23-130
_______________________________________________
Dancer-users mailing list
[email protected]
http://www.backup-manager.org/cgi-bin/listinfo/dancer-users