Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b21db5cf22 | ||
|
|
24990483e5 | ||
|
|
4f5d3a0951 | ||
|
|
a72ec0e750 | ||
|
|
2956335d9e | ||
|
|
7d1ac4eecd | ||
|
|
28ae3d62f8 |
@@ -1,6 +1,11 @@
|
|||||||
Revision history for Mojolicious::Plugin::TtRenderer
|
Revision history for Mojolicious::Plugin::TtRenderer
|
||||||
|
|
||||||
{{$NEXT}}
|
{{$NEXT}}
|
||||||
|
- Compatibility with Mojolicious 3.05+ (GH#24)
|
||||||
|
- Avoid deep recursion when exception template dies (GH#25,GH26)
|
||||||
|
- Fixed test failures (GH#27,GH#28)
|
||||||
|
|
||||||
|
1.21 June 5, 2012
|
||||||
- Fixed double TT rendering on error (Matthias Bethke (GH#21))
|
- Fixed double TT rendering on error (Matthias Bethke (GH#21))
|
||||||
- Cache templates in tmpdir by default (Marcus Ramberg)
|
- Cache templates in tmpdir by default (Marcus Ramberg)
|
||||||
- Require Mojolicious 2.51 to avoid memory leaks (GH#19)
|
- Require Mojolicious 2.51 to avoid memory leaks (GH#19)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package Mojolicious::Plugin::TtRenderer::Engine;
|
|||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
use v5.10;
|
||||||
|
|
||||||
use base 'Mojo::Base';
|
use base 'Mojo::Base';
|
||||||
|
|
||||||
@@ -88,12 +89,19 @@ sub _render {
|
|||||||
# Error
|
# Error
|
||||||
unless ($ok) {
|
unless ($ok) {
|
||||||
|
|
||||||
|
state $rendering_exception;
|
||||||
|
|
||||||
my $e = Mojo::Exception->new($self->tt->error.'');
|
my $e = Mojo::Exception->new($self->tt->error.'');
|
||||||
$$output = '';
|
$$output = '';
|
||||||
$c->app->log->error(qq/Template error in "$t": $e/);
|
$c->app->log->error(qq/Template error in "$t": $e/);
|
||||||
$c->render_exception($e);
|
|
||||||
$self->tt->error('');
|
unless($rendering_exception)
|
||||||
return 0;
|
{
|
||||||
|
$rendering_exception = 1;
|
||||||
|
$c->render_exception($e);
|
||||||
|
$rendering_exception = 0;
|
||||||
|
$self->tt->error('');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
#BEGIN { $ENV{MOJO_MODE}='testing'; };
|
||||||
|
|
||||||
|
use utf8;
|
||||||
|
|
||||||
|
use Test::More tests => 3;
|
||||||
|
|
||||||
|
use Mojolicious::Lite;
|
||||||
|
use Test::Mojo;
|
||||||
|
|
||||||
|
# Silence
|
||||||
|
app->log->level('fatal');
|
||||||
|
|
||||||
|
plugin 'tt_renderer';
|
||||||
|
|
||||||
|
get '/exception' => sub { die };
|
||||||
|
|
||||||
|
#say app->mode;
|
||||||
|
#app->start;
|
||||||
|
#exit;
|
||||||
|
|
||||||
|
my $t = Test::Mojo->new;
|
||||||
|
|
||||||
|
$t->app->renderer->default_handler('tt');
|
||||||
|
|
||||||
|
my $deep_recursion = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
local $SIG{__WARN__} = sub {
|
||||||
|
my $warning = shift;
|
||||||
|
if($warning =~ /Deep recursion/) {
|
||||||
|
$deep_recursion = 1;
|
||||||
|
die $warning;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
$t->get_ok('/exception')
|
||||||
|
->status_is(500);
|
||||||
|
};
|
||||||
|
|
||||||
|
ok !$deep_recursion, 'no deep recursion';
|
||||||
|
|
||||||
|
__DATA__
|
||||||
|
|
||||||
|
@@ exception.development.html.tt
|
||||||
|
[% 1 + % %]
|
||||||
|
|
||||||
|
@@ exception.html.tt
|
||||||
|
[% 1 + % %]
|
||||||
|
|
||||||
|
@@ exception.testing.html.tt
|
||||||
|
[% 1 + % %]
|
||||||
+4
-1
@@ -15,4 +15,7 @@ eval "use Pod::Coverage $min_pc";
|
|||||||
plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
|
plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
|
||||||
if $@;
|
if $@;
|
||||||
|
|
||||||
all_pod_coverage_ok();
|
plan tests => 2;
|
||||||
|
|
||||||
|
pod_coverage_ok('Mojolicious::Plugin::TtRenderer');
|
||||||
|
pod_coverage_ok('Mojolicious::Plugin::TtRenderer::Engine', { also_private => [qr{^tt$}] } );
|
||||||
|
|||||||
+13
-6
@@ -43,10 +43,17 @@ $t->get_ok('/')->status_is(200)
|
|||||||
->content_like(qr/test123456/);
|
->content_like(qr/test123456/);
|
||||||
$t->get_ok('/blow')->status_is(500)->content_like(qr/file error - doesnotexist.tt: No such file or directory/);
|
$t->get_ok('/blow')->status_is(500)->content_like(qr/file error - doesnotexist.tt: No such file or directory/);
|
||||||
|
|
||||||
eval "
|
if(eval q{ use Devel::Cycle; 1 })
|
||||||
use Devel::Cycle 'find_cycle';
|
{
|
||||||
find_cycle(app, sub {
|
Devel::Cycle::find_cycle(app, sub {
|
||||||
ok(0, 'Cycle found');
|
my $arg = shift;
|
||||||
|
# Template::Provider (from which M::P::T::Provider inherits) has some cycles which are freed manaully by
|
||||||
|
# its DESTROY method, so we skip reporting those cycles.
|
||||||
|
unless(scalar(scalar(grep { ref($_->[2]) eq 'Mojolicious::Plugin::TtRenderer::Provider' && $_->[1] =~ /^(HEAD|TAIL|LOOKUP)$/ } @$arg)) > 0)
|
||||||
|
{
|
||||||
|
#use YAML ();
|
||||||
|
#diag YAML::Dump([ map { [ $_->[0], $_->[1], ref($_->[2]), ref($_->[3]) ] } @$arg ]);
|
||||||
|
fail('Cycle found')
|
||||||
|
}
|
||||||
});
|
});
|
||||||
";
|
};
|
||||||
|
|
||||||
Reference in New Issue
Block a user