Skip to content

Commit

Permalink
small optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jan 5, 2013
1 parent d6e4c19 commit c292e76
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions lib/Mojolicious/Renderer.pm
Expand Up @@ -27,17 +27,8 @@ sub new {
return $self->add_handler(data => \&_data)->add_handler(text => \&_text);
}

sub add_handler {
my ($self, $name, $cb) = @_;
$self->handlers->{$name} = $cb;
return $self;
}

sub add_helper {
my ($self, $name, $cb) = @_;
$self->helpers->{$name} = $cb;
return $self;
}
sub add_handler { shift->_add(handlers => @_) }
sub add_helper { shift->_add(helpers => @_) }

sub get_data_template {
my ($self, $options) = @_;
Expand Down Expand Up @@ -158,6 +149,12 @@ sub template_path {
return catfile($self->paths->[0], split '/', $name);
}

sub _add {
my ($self, $attr, $name, $cb) = @_;
$self->$attr->{$name} = $cb;
return $self;
}

sub _bundled { $TEMPLATES{"@{[pop]}.html.ep"} }

sub _data {
Expand Down

0 comments on commit c292e76

Please sign in to comment.