Skip to content

Commit

Permalink
simplify renderer requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 23, 2012
1 parent d3c0725 commit 3fee419
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
5 changes: 1 addition & 4 deletions lib/Mojolicious/Guides/Rendering.pod
Expand Up @@ -887,11 +887,8 @@ do is add a new C<handler>.
# One time use inline template
my $inline = $options->{inline};

# Generate relative template path
my $name = $r->template_name($options);

# Try to find appropriate template in DATA section
my $content = $r->get_data_template($options, $name);
my $content = $r->get_data_template($options);

# Generate absolute template path
my $path = $r->template_path($options);
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Plugin/EPLRenderer.pm
Expand Up @@ -54,7 +54,7 @@ sub _epl {
}

# Try DATA section
elsif (my $d = $r->get_data_template($options, $t)) {
elsif (my $d = $r->get_data_template($options)) {
$c->app->log->debug(qq{Rendering template "$t" from DATA section.});
$mt->name(qq{template "$t" from DATA section});
$$output = $mt->render($d, $c);
Expand Down
5 changes: 3 additions & 2 deletions lib/Mojolicious/Renderer.pm
Expand Up @@ -43,7 +43,7 @@ sub add_helper {
}

sub get_data_template {
my ($self, $options, $template) = @_;
my ($self, $options) = @_;

# Index DATA templates
my $loader = Mojo::Loader->new;
Expand All @@ -55,6 +55,7 @@ sub get_data_template {
}

# Find template
my $template = $self->template_name($options);
return $loader->data($self->{index}{$template}, $template);
}

Expand Down Expand Up @@ -343,7 +344,7 @@ Register a new helper.
template => 'foo/bar',
format => 'html',
handler => 'epl'
}, 'foo.html.ep');
});
Get a C<DATA> section template by name, usually used by handlers.
Expand Down

0 comments on commit 3fee419

Please sign in to comment.