Skip to content

Commit

Permalink
simplify multiline handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Sep 2, 2014
1 parent d36f69a commit c046fd2
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/Mojo/Template.pm
Expand Up @@ -46,12 +46,11 @@ sub build {
$blocks[-1] .= 'return Mojo::ByteStream->new($_M) }';

# No following code
my $next = $block->[$i + 1];
$blocks[-1] .= ';' if !defined $next->[1] || $next->[1] =~ /^\s*$/;
$blocks[-1] .= ';' if ($block->[$i + 1][1] // '') =~ /^\s*$/;
}

# Code or multiline expression
elsif ($op eq 'code' || $multi) { $blocks[-1] .= "$value" }
elsif ($op eq 'code' || $multi) { $blocks[-1] .= $value }

# Expression
if ($op eq 'expr' || $op eq 'escp') {
Expand All @@ -69,8 +68,7 @@ sub build {
}

# Multiline
my $previous = $block->[$i + 1] || [''];
$multi = $previous->[0] ne 'text' || $previous->[1] ne '';
$multi = !$block->[$i + 1] || $block->[$i + 1][0] eq 'code';

# Append semicolon
$blocks[-1] .= ';' unless $multi || $capture;
Expand Down

0 comments on commit c046fd2

Please sign in to comment.