From 2d0480d6ff96b3a89400fc6db137a875ebd095ee Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 4 Oct 2012 16:42:47 -0500 Subject: standalone lines need to be autochomped in raw_text too --- lib/Text/Xslate/Syntax/Handlebars.pm | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/lib/Text/Xslate/Syntax/Handlebars.pm b/lib/Text/Xslate/Syntax/Handlebars.pm index 3494f45..d99f3d0 100644 --- a/lib/Text/Xslate/Syntax/Handlebars.pm +++ b/lib/Text/Xslate/Syntax/Handlebars.pm @@ -55,20 +55,6 @@ sub split_tags { or die "Oops!"; my @extra; - if ($code =~ m{^/}) { - push @extra, pop @raw_text; - push @extra, pop @delimiters; - if (@raw_text) { - $raw_text[-1] .= $extra[0]; - } - } - if (@raw_text) { - $raw_text[-1] .= $tag_start . $code . $tag_end; - } - if ($code =~ m{^[#^]}) { - push @raw_text, ''; - push @delimiters, [$tag_start, $tag_end]; - } my $autochomp = $code =~ m{^[!#^/=>]}; @@ -84,6 +70,9 @@ sub split_tags { $input =~ s/\A$nl//; if (@chunks > 0 && $chunks[-1][0] eq 'text' && $code !~ m{^>}) { $chunks[-1][1] =~ s/^(?:(?!\n)\s)*\z//m; + if (@raw_text) { + $raw_text[-1] =~ s/^(?:(?!\n)\s)*\z//m; + } } } } @@ -91,6 +80,21 @@ sub split_tags { $standalone = 0; } + if ($code =~ m{^/}) { + push @extra, pop @raw_text; + push @extra, pop @delimiters; + if (@raw_text) { + $raw_text[-1] .= $extra[0]; + } + } + if (@raw_text) { + $raw_text[-1] .= $tag_start . $code . $tag_end; + } + if ($code =~ m{^[#^]}) { + push @raw_text, ''; + push @delimiters, [$tag_start, $tag_end]; + } + if (length($code)) { push @chunks, [ ($close_tag eq '}}}' ? 'raw_code' : 'code'), -- cgit v1.2.3-54-g00ecf