Skip to content

Commit

Permalink
hide escape function
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 24, 2012
1 parent 8b4c807 commit 3246b9c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/Mojo/Template.pm
Expand Up @@ -28,7 +28,7 @@ has tree => sub { [] };
my $HELPERS = <<'EOF';
use Mojo::Util;
no warnings 'redefine';
sub escape {
sub _escape {
return $_[0] if ref $_[0] eq 'Mojo::ByteStream';
no warnings 'uninitialized';
Mojo::Util::xml_escape "$_[0]";
Expand Down Expand Up @@ -84,7 +84,7 @@ sub build {
# Escaped
my $a = $self->auto_escape;
if (($type eq 'escp' && !$a) || ($type eq 'expr' && $a)) {
$lines[-1] .= "\$_M .= escape";
$lines[-1] .= "\$_M .= _escape";
$lines[-1] .= " scalar $value" if length $value;
}

Expand Down
18 changes: 9 additions & 9 deletions t/mojo/template.t
Expand Up @@ -273,55 +273,55 @@ is $output, "<html>\n\n", 'escaped expression block';
# Capture lines (passed through with extra whitespace)
$mt = Mojo::Template->new(prepend => $capture);
$output = $mt->render(<<'EOF');
<% my $result = escape capture begin %>
<% my $result = capture begin %>
<html>
<% end %>
%= $result
%== $result
EOF
is $output, "\n\n<html>\n\n", 'captured lines';

# Capture tags (passed through)
$mt = Mojo::Template->new(prepend => $capture);
$output = $mt->render(<<'EOF');
<% my $result = escape capture begin %><html><% end %><%= $result %>
<% my $result = capture begin %><html><% end %><%== $result %>
EOF
is $output, "<html>\n", 'capture tags';

# Capture tags (passed through alternative)
$mt = Mojo::Template->new(prepend => $capture);
$output = $mt->render(<<'EOF');
<% my $result = escape capture begin %><html><% end %><%= $result %>
<% my $result = capture begin %><html><% end %><%== $result %>
EOF
is $output, "<html>\n", 'capture tags';

# Capture tags with appended code (passed through)
$mt = Mojo::Template->new(prepend => $capture);
$output = $mt->render(<<'EOF');
<% my $result = escape( capture begin %><html><% end ); %><%= $result %>
<% my $result = +(capture begin %><html><% end); %><%== $result %>
EOF
is $output, "<html>\n", 'capture tags with appended code';

# Capture tags with appended code (passed through alternative)
$mt = Mojo::Template->new(prepend => $capture);
$output = $mt->render(<<'EOF');
<% my $result = escape( capture begin %><html><% end ); %><%= $result %>
<% my $result = +( capture begin %><html><% end ); %><%= $result %>
EOF
is $output, "<html>\n", 'capture tags with appended code';

# Nested capture tags (passed through)
$mt = Mojo::Template->new(prepend => $capture);
$output = $mt->render(<<'EOF');
<% my $result = capture
begin %><%= escape capture begin %><html><% end
%><% end %><%= $result %>
begin %><%= capture begin %><html><% end
%><% end %><%== $result %>
EOF
is $output, "<html>\n", 'nested capture tags';

# Nested capture tags (passed through alternative)
$mt = Mojo::Template->new(prepend => $capture);
$output = $mt->render(<<'EOF');
<% my $result = capture begin =%>
<%= escape capture begin =%>
<%== capture begin =%>
<html>
<% end =%>
<% end =%>
Expand Down

0 comments on commit 3246b9c

Please sign in to comment.