Skip to content

Commit

Permalink
Merge branch 'topic/fix-template-extension' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexis Sukrieh committed Feb 5, 2011
2 parents 07813af + 44e2d08 commit 861f84f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
6 changes: 2 additions & 4 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@

* Eliminate test warnings on Windows.
(Gabor Szabo)

* GH#271 - use correct VERSION_FROM in scaffolded application.
(Sawyer X)

* GH#260 - send_file doesn't clobber existing headers
(Alexis Sukrieh)

* logger unicode bugfix in the formated date
(jahmed)

* GH#281 - Don't crash if splat is used with no captures
(David Precious)
* Possible to given "template" a view name with the extenstion.
(Alexis Sukrieh)

[ ENHANCEMENTS ]

Expand Down
3 changes: 2 additions & 1 deletion lib/Dancer/Template/Abstract.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ sub default_tmpl_ext { "tt" }
sub _template_name {
my ( $self, $view ) = @_;
my $def_tmpl_ext = $self->config->{extension} || $self->default_tmpl_ext();
$view .= ".$def_tmpl_ext" if $view !~ /\.${def_tmpl_ext}$/;
$view .= ".$def_tmpl_ext" if $view !~ /\.\Q$def_tmpl_ext\E$/;
return $view;
}

sub view {
Expand Down
19 changes: 19 additions & 0 deletions t/10_template/template.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use Test::More import => ['!pass'];

plan tests => 1;

use strict;
use warnings;

{
use Dancer;

setting views => path('t', '10_template', 'views');
get '/' => sub {
template 'index.tt', {foo => 42};
};
}

use Dancer::Test;

response_content_is [GET => '/'], "foo => 42\n";

0 comments on commit 861f84f

Please sign in to comment.