Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Dancer CPAN distribution.

Report information
The Basics
Id: 58181
Status: rejected
Priority: 0/
Queue: Dancer

People
Owner: Nobody in particular
Requestors: richard_david_evans [...] yahoo.co.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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 ||= {};
Hmm... could you be more precise, what call exactly does fail? We have the following statement in a test script, and it works perfectly: # in t/10_template/05_template_toolkit.t # ... $result = $engine->render(\$template, { one => 1, two => 2, three => 3}); is $result, $expected, "processed a template given as a scalar ref";
Subject: Re: [Bulk] [rt.cpan.org #58181] Template rendering fails with scalar references
Date: Fri, 18 Jun 2010 15:47:25 +0100
To: bug-Dancer [...] rt.cpan.org
From: Richard Evans <richard_david_evans [...] yahoo.co.uk>
Sorry, down to me not RTFM properly - was looking at Dancer::Template::Abstract docs and assuming I could render scalar contents by calling: template \$template, {...}; Double checking the Dancer.pm docs that clearly isn't correct - feel free to close case and apologies for time wasted. Best wishes Richard