Skip to content

Commit

Permalink
fixed a case where an ending tag would be interpreted as a line start…
Browse files Browse the repository at this point in the history
… in Mojo::Template
  • Loading branch information
kraih committed Dec 14, 2009
1 parent 0e7fc25 commit 0aa25f4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Changes
Expand Up @@ -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.
Expand Down
14 changes: 5 additions & 9 deletions lib/Mojo/Template.pm
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
13 changes: 11 additions & 2 deletions t/mojo/template.t
Expand Up @@ -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;
Expand Down Expand Up @@ -434,7 +434,16 @@ $output = $mt->render(<<'EOF');
$i x 4; }; %>\
</html>\
EOF
is($output, "<html>2222</html>");
is($output, '<html>2222</html>');

# 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;
Expand Down

0 comments on commit 0aa25f4

Please sign in to comment.