diff --git a/Changes b/Changes index f779424d25..3eaba5564f 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,8 @@ This file documents the revision history for Perl extension Mojo. 0.999915 2009-12-10 00:00:00 - Added routes captures to params in Mojolicious. + - Fixed a case where an ending tag would be interpreted as a line + start in Mojo::Template. 0.999914 2009-11-24 00:00:00 - Added the Mojolicious plugin system. diff --git a/lib/Mojo/Template.pm b/lib/Mojo/Template.pm index 2a749a5d1f..8ba431e4fb 100644 --- a/lib/Mojo/Template.pm +++ b/lib/Mojo/Template.pm @@ -270,7 +270,7 @@ sub parse { } # Perl line without return value - if ($line =~ /^$line_start(.+)?$/) { + if ($line =~ /^$line_start([^\>]{1}.*)?$/) { push @{$self->tree}, [@capture, 'code', $1]; $multiline_expression = 0; next; @@ -541,16 +541,12 @@ Like preprocessing a config file, generating text from heredocs and stuff like that. <% Inline Perl %> - <%= Perl expression, replaced with result or XML escaped result - (depending on auto_escape attribute) %> - <%== Perl expression, replaced with result or XML escaped result - (depending on auto_escape attribute) %> + <%= Perl expression, replaced with result %> + <%== Perl expression, replaced with XML escaped result %> <%# Comment, useful for debugging %> % Perl line - %= Perl expression line, replaced with result or XML escaped result - (depending on auto_escape attribute) - %== Perl expression line, replaced with result or XML escaped result - (depending on auto_escape attribute) + %= Perl expression line, replaced with result + %== Perl expression line, replaced with XML escaped result %# Comment line, useful for debugging Whitespace characters around tags can be trimmed with a special tag ending. diff --git a/t/mojo/template.t b/t/mojo/template.t index e8a705e146..9d080c3f69 100644 --- a/t/mojo/template.t +++ b/t/mojo/template.t @@ -25,7 +25,7 @@ package main; use strict; use warnings; -use Test::More tests => 84; +use Test::More tests => 85; use File::Spec; use File::Temp; @@ -434,7 +434,16 @@ $output = $mt->render(<<'EOF'); $i x 4; }; %>\ \ EOF -is($output, "2222"); +is($output, '2222'); + +# Different multiline expression +$mt = Mojo::Template->new; +$output = $mt->render(<<'EOF'); +<%= do { my $i = '2'; + $i x 4; }; +%>\ +EOF +is($output, '2222'); # Different tags and line start $mt = Mojo::Template->new;