Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Allow refs to pass through view unscathed
Useful for inline templates so that you don't necessarily need a
directory structure or external files.

Also, the underlying template implementation supports passing a
scalar ref, but without the high-level implementation also supporting
this, there's no way to do inline templates with hooks.
  • Loading branch information
perlpilot committed Dec 8, 2011
commit d9ebf538b28929ed6197e140cc6183e8ae178f55
3 changes: 2 additions & 1 deletion lib/Dancer/Template/Abstract.pm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ sub default_tmpl_ext { "tt" }

sub _template_name {
my ( $self, $view ) = @_;
return $view if ref($view);
my $def_tmpl_ext = $self->config->{extension} || $self->default_tmpl_ext();
$view .= ".$def_tmpl_ext" if $view !~ /\.\Q$def_tmpl_ext\E$/;
return $view;
Expand All @@ -33,7 +34,7 @@ sub view {

$view = $self->_template_name($view);

return path(Dancer::App->current->setting('views'), $view);
return ref($view) ? $view : path(Dancer::App->current->setting('views'), $view);
}

sub layout {
Expand Down