Skip to content

Commit

Permalink
count lines a little more efficiently
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 8, 2014
1 parent 096c98d commit 262c2cd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Mojo/Template.pm
Expand Up @@ -283,11 +283,11 @@ sub _wrap {
};

# Wrap lines
my $last = scalar split "\n", $code;
my $num = () = $code =~ /\n/g;
my $head = $self->_line(1);
$head .= "\npackage @{[$self->namespace]}; use Mojo::Base -strict;";
$code = "$head sub { my \$_M = ''; @{[$self->prepend]}; do { $code\n";
$code .= $self->_line($last) . "\n@{[$self->append]}; \$_M } };";
$code .= $self->_line($num + 1) . "\n@{[$self->append]}; \$_M } };";

warn "-- Code for @{[$self->name]}\n@{[encode 'UTF-8', $code]}\n\n" if DEBUG;
return $code;
Expand Down

0 comments on commit 262c2cd

Please sign in to comment.