Subject: | Template rendering fails with scalar references |
Date: | Mon, 7 Jun 2010 01:40:58 +0100 |
To: | bug-Dancer [...] rt.cpan.org |
From: | Richard Evans <richard_david_evans [...] yahoo.co.uk> |
Hello
Dancer-1.1803
Template rendering is failing with scalar references, eg:
my $template = "foo";
render \$template; #### <<< Gives "error 404, page not found" instead of rendering the scalar contents.
The following fixes ref handling in Dancer::Helpers::template.
Best wishes
Richard
--- Helpers.pm 2010-06-07 00:08:30.000000000 +0000
+++ Helpers.pm.new 2010-06-07 00:12:30.000000000 +0000
@@ -36,15 +36,17 @@
my $layout = setting('layout');
undef $layout unless $options->{layout};
- $view .= ".tt" if $view !~ /\.tt$/;
- $view = path(setting('views'), $view);
-
- if (! -r $view) {
- my $error = Dancer::Error->new(
- code => 404,
- message => "Page not found",
- );
- return Dancer::Response::set($error->render);
+ unless ( ref($view) eq 'SCALAR' ) {
+ $view .= ".tt" if $view !~ /\.tt$/;
+ $view = path(setting('views'), $view);
+
+ if (! -r $view) {
+ my $error = Dancer::Error->new(
+ code => 404,
+ message => "Page not found",
+ );
+ return Dancer::Response::set($error->render);
+ }
}
$tokens ||= {};