From 898af35396b15c98d14951ada99fedc2f087ed9e Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 3 Oct 2012 12:11:49 -0500 Subject: standalone lines must only be followed by whitespace as well --- lib/Text/Xslate/Syntax/Handlebars.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Text/Xslate/Syntax/Handlebars.pm b/lib/Text/Xslate/Syntax/Handlebars.pm index b43fcd7..e10e52b 100644 --- a/lib/Text/Xslate/Syntax/Handlebars.pm +++ b/lib/Text/Xslate/Syntax/Handlebars.pm @@ -54,9 +54,11 @@ sub split_tags { or die "Oops!"; if ($code =~ m{^[!#^/]} && $standalone) { - $input =~ s/\A$nl//; - if (@chunks > 0 && $chunks[-1][0] eq 'text') { - $chunks[-1][1] =~ s/^(?:(?!\n)\s)*\z//m; + if ($input =~ /\A\s*(?:\n|\z)/) { + $input =~ s/\A$nl//; + if (@chunks > 0 && $chunks[-1][0] eq 'text') { + $chunks[-1][1] =~ s/^(?:(?!\n)\s)*\z//m; + } } } -- cgit v1.2.3-54-g00ecf