diff options
author | Jesse Luehrs <doy@tozt.net> | 2012-10-04 16:42:47 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2012-10-04 16:42:47 -0500 |
commit | 2d0480d6ff96b3a89400fc6db137a875ebd095ee (patch) | |
tree | 03602a0d5e11d873a3786ade25a8b37bb41fc5e8 /lib/Text/Xslate | |
parent | 57ea0e7ab1189cd2d1e72ae48a32696095d4f2f7 (diff) | |
download | text-handlebars-2d0480d6ff96b3a89400fc6db137a875ebd095ee.tar.gz text-handlebars-2d0480d6ff96b3a89400fc6db137a875ebd095ee.zip |
standalone lines need to be autochomped in raw_text too
Diffstat (limited to 'lib/Text/Xslate')
-rw-r--r-- | lib/Text/Xslate/Syntax/Handlebars.pm | 32 |
1 files 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'), |