Compare commits
9 Commits
release/1.
...
release/1.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7455ae1be8 | ||
|
|
870d195761 | ||
|
|
b21db5cf22 | ||
|
|
24990483e5 | ||
|
|
4f5d3a0951 | ||
|
|
a72ec0e750 | ||
|
|
2956335d9e | ||
|
|
7d1ac4eecd | ||
|
|
28ae3d62f8 |
8
Changes
8
Changes
@@ -1,6 +1,14 @@
|
||||
Revision history for Mojolicious::Plugin::TtRenderer
|
||||
|
||||
{{$NEXT}}
|
||||
- Use die instead of render_exception (GH#29)
|
||||
|
||||
1.22 August 21, 2012
|
||||
- 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))
|
||||
- Cache templates in tmpdir by default (Marcus Ramberg)
|
||||
- Require Mojolicious 2.51 to avoid memory leaks (GH#19)
|
||||
|
||||
1
dist.ini
1
dist.ini
@@ -39,7 +39,6 @@ version_regexp = ^release/(.*)
|
||||
[HasVersionTests]
|
||||
[MetaTests]
|
||||
[ReadmeFromPod]
|
||||
[PodCoverageTests]
|
||||
[Manifest]
|
||||
|
||||
[NextRelease]
|
||||
|
||||
@@ -2,6 +2,7 @@ package Mojolicious::Plugin::TtRenderer::Engine;
|
||||
|
||||
use warnings;
|
||||
use strict;
|
||||
use v5.10;
|
||||
|
||||
use base 'Mojo::Base';
|
||||
|
||||
@@ -30,7 +31,7 @@ sub _init {
|
||||
my $dir;
|
||||
my $app = delete $args{mojo} || delete $args{app};
|
||||
if($dir=$args{cache_dir}) {
|
||||
|
||||
|
||||
if($app && substr($dir,0,1) ne '/') {
|
||||
$dir=$app->home->rel_dir('tmp/ctpl');
|
||||
}
|
||||
@@ -86,15 +87,7 @@ sub _render {
|
||||
my $ok = $self->tt->process(defined $inline ? \$inline : $t, @params);
|
||||
|
||||
# Error
|
||||
unless ($ok) {
|
||||
|
||||
my $e = Mojo::Exception->new($self->tt->error.'');
|
||||
$$output = '';
|
||||
$c->app->log->error(qq/Template error in "$t": $e/);
|
||||
$c->render_exception($e);
|
||||
$self->tt->error('');
|
||||
return 0;
|
||||
}
|
||||
die $self->tt->error unless $ok;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
55
t/deep_recursion.t
Normal file
55
t/deep_recursion.t
Normal file
@@ -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 + % %]
|
||||
@@ -15,4 +15,7 @@ eval "use Pod::Coverage $min_pc";
|
||||
plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
|
||||
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$}] } );
|
||||
|
||||
@@ -43,10 +43,17 @@ $t->get_ok('/')->status_is(200)
|
||||
->content_like(qr/test123456/);
|
||||
$t->get_ok('/blow')->status_is(500)->content_like(qr/file error - doesnotexist.tt: No such file or directory/);
|
||||
|
||||
eval "
|
||||
use Devel::Cycle 'find_cycle';
|
||||
find_cycle(app, sub {
|
||||
ok(0, 'Cycle found');
|
||||
if(eval q{ use Devel::Cycle; 1 })
|
||||
{
|
||||
Devel::Cycle::find_cycle(app, sub {
|
||||
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