Compare commits
37
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7455ae1be8 | ||
|
|
870d195761 | ||
|
|
b21db5cf22 | ||
|
|
24990483e5 | ||
|
|
4f5d3a0951 | ||
|
|
a72ec0e750 | ||
|
|
2956335d9e | ||
|
|
7d1ac4eecd | ||
|
|
28ae3d62f8 | ||
|
|
944fa2ecae | ||
|
|
3364b8a05a | ||
|
|
6047db4ef2 | ||
|
|
b37a7639d3 | ||
|
|
511ee4463b | ||
|
|
bdc9f56452 | ||
|
|
618adbd774 | ||
|
|
c0b649d55f | ||
|
|
1e1a9ab835 | ||
|
|
96d31d45a0 | ||
|
|
bbfab8db4e | ||
|
|
92bb64406b | ||
|
|
989ea57cf9 | ||
|
|
b3c64c75d4 | ||
|
|
a89a9a4344 | ||
|
|
78c9d24bc7 | ||
|
|
859ec53953 | ||
|
|
0b0acd510e | ||
|
|
0527eee24a | ||
|
|
bd48aa5066 | ||
|
|
77b9531fae | ||
|
|
248f13717a | ||
|
|
9f20c780b8 | ||
|
|
c7c249b51f | ||
|
|
dae8329981 | ||
|
|
5e650027c7 | ||
|
|
698fc48b58 | ||
|
|
49075ebe44 |
@@ -6,6 +6,7 @@ _build*
|
|||||||
pm_to_blib*
|
pm_to_blib*
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
.lwpcookies
|
.lwpcookies
|
||||||
|
Mojolicious-Plugin-TtRenderer-*
|
||||||
MojoX-Renderer-TT-*
|
MojoX-Renderer-TT-*
|
||||||
cover_db
|
cover_db
|
||||||
*~
|
*~
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
language: perl
|
||||||
|
install:
|
||||||
|
- cpanm Mojolicious Template
|
||||||
|
script: HARNESS_IS_VERBOSE=1 prove -v -Ilib t
|
||||||
|
perl:
|
||||||
|
- "5.14"
|
||||||
|
- "5.12"
|
||||||
|
- "5.10"
|
||||||
@@ -1,6 +1,29 @@
|
|||||||
Revision history for MojoX-Renderer-TT
|
Revision history for Mojolicious::Plugin::TtRenderer
|
||||||
|
|
||||||
{{$NEXT}}
|
{{$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)
|
||||||
|
- Document the 'c' stash variable (RT#70866, Matthias Bethke)
|
||||||
|
- Fix memory leaks, add tests for them (GH#18, Magnus Holm)
|
||||||
|
- Use app->renderer->paths to find template directories (GH#17)
|
||||||
|
|
||||||
|
1.20 August 1, 2011
|
||||||
|
- Drop use of MojoX namespace for Mojolicious::Plugin::TtRenderer::
|
||||||
|
(GH#12, Cosimo Streppone)
|
||||||
|
|
||||||
|
1.13 June 7, 2011
|
||||||
|
- Compatibility with Mojolicious 1.3+
|
||||||
|
|
||||||
|
1.12 February 28, 2011
|
||||||
- Inline wrappers and includes now work on Windows
|
- Inline wrappers and includes now work on Windows
|
||||||
(GH#13, Christiaan Kras)
|
(GH#13, Christiaan Kras)
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
# Avoid Makemaker generated and utility files.
|
# Avoid Makemaker generated and utility files.
|
||||||
\bMANIFEST\.bak
|
\bMANIFEST\.bak
|
||||||
|
\bMYMETA.*
|
||||||
\bMakefile$
|
\bMakefile$
|
||||||
\bblib/
|
\bblib/
|
||||||
\bMakeMaker-\d
|
\bMakeMaker-\d
|
||||||
@@ -41,6 +42,3 @@ t/tmp/ctpl
|
|||||||
\.t\.log$
|
\.t\.log$
|
||||||
|
|
||||||
\.prove$
|
\.prove$
|
||||||
|
|
||||||
# XS shit
|
|
||||||
\.(?:bs|c|o)$
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name = MojoX-Renderer-TT
|
name = Mojolicious-Plugin-TtRenderer
|
||||||
author = Ask Bjørn Hansen <ask@develooper.com>
|
author = Ask Bjørn Hansen <ask@develooper.com>
|
||||||
license = Perl_5
|
license = Perl_5
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ copyright_holder = Ask Bjørn Hansen
|
|||||||
# copyright_year = 2009
|
# copyright_year = 2009
|
||||||
|
|
||||||
[Prereqs]
|
[Prereqs]
|
||||||
Mojolicious = 1.01
|
Mojolicious = 2.51
|
||||||
Template = 2.18
|
Template = 2.18
|
||||||
|
|
||||||
[Prereqs / TestRequires ]
|
[Prereqs / TestRequires ]
|
||||||
@@ -35,12 +35,10 @@ version_regexp = ^release/(.*)
|
|||||||
[PkgVersion]
|
[PkgVersion]
|
||||||
|
|
||||||
[CheckChangeLog]
|
[CheckChangeLog]
|
||||||
[CompileTests]
|
[Test::Compile]
|
||||||
[DistManifestTests]
|
|
||||||
[HasVersionTests]
|
[HasVersionTests]
|
||||||
[MetaTests]
|
[MetaTests]
|
||||||
[ReadmeFromPod]
|
[ReadmeFromPod]
|
||||||
[PodCoverageTests]
|
|
||||||
[Manifest]
|
[Manifest]
|
||||||
|
|
||||||
[NextRelease]
|
[NextRelease]
|
||||||
|
|||||||
@@ -3,23 +3,23 @@ package Mojolicious::Plugin::TtRenderer;
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
our $VERSION = '0.01';
|
|
||||||
|
|
||||||
use base 'Mojolicious::Plugin';
|
use base 'Mojolicious::Plugin';
|
||||||
|
|
||||||
use MojoX::Renderer::TT;
|
use Mojolicious::Plugin::TtRenderer::Engine;
|
||||||
|
|
||||||
sub register {
|
sub register {
|
||||||
my ($self, $app, $args) = @_;
|
my ($self, $app, $args) = @_;
|
||||||
|
|
||||||
$args ||= {};
|
$args ||= {};
|
||||||
|
|
||||||
my $tt = MojoX::Renderer::TT->build(%$args, app => $app);
|
my $tt = Mojolicious::Plugin::TtRenderer::Engine->build(%$args, app => $app);
|
||||||
|
|
||||||
# Add "tt" handler
|
# Add "tt" handler
|
||||||
$app->renderer->add_handler(tt => $tt);
|
$app->renderer->add_handler(tt => $tt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local ($Mojolicious::Plugin::TtRenderer::VERSION) = ('devel') unless defined $Mojolicious::Plugin::TtRenderer::VERSION;
|
||||||
|
|
||||||
1;
|
1;
|
||||||
__END__
|
__END__
|
||||||
|
|
||||||
@@ -52,8 +52,14 @@ L<Mojolicious::Plugin> and implements the following new ones.
|
|||||||
|
|
||||||
Register renderer in L<Mojolicious> application.
|
Register renderer in L<Mojolicious> application.
|
||||||
|
|
||||||
|
=head1 EXTRA STASH VARIABLES
|
||||||
|
|
||||||
|
The current controller instance can be accessed as C<c>.
|
||||||
|
|
||||||
|
[% c.req.headers.host %]
|
||||||
|
|
||||||
=head1 SEE ALSO
|
=head1 SEE ALSO
|
||||||
|
|
||||||
L<MojoX::Renderer::TT>, L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicious.org>.
|
L<Mojolicious::Plugin::TtRenderer::Engine>, L<Mojolicious>, L<Mojolicious::Guides>, L<http://mojolicious.org>.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|||||||
@@ -1,19 +1,23 @@
|
|||||||
package MojoX::Renderer::TT;
|
package Mojolicious::Plugin::TtRenderer::Engine;
|
||||||
|
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
|
use v5.10;
|
||||||
|
|
||||||
use base 'Mojo::Base';
|
use base 'Mojo::Base';
|
||||||
|
|
||||||
|
use Carp ();
|
||||||
use File::Spec ();
|
use File::Spec ();
|
||||||
use Mojo::ByteStream 'b';
|
use Mojo::ByteStream 'b';
|
||||||
use Template ();
|
use Template ();
|
||||||
use Cwd qw/abs_path/;
|
use Cwd qw/abs_path/;
|
||||||
|
use Scalar::Util 'weaken';
|
||||||
|
|
||||||
__PACKAGE__->attr('tt');
|
__PACKAGE__->attr('tt');
|
||||||
|
|
||||||
sub build {
|
sub build {
|
||||||
my $self = shift->SUPER::new(@_);
|
my $self = shift->SUPER::new(@_);
|
||||||
|
weaken($self->{app});
|
||||||
$self->_init(@_);
|
$self->_init(@_);
|
||||||
return sub { $self->_render(@_) }
|
return sub { $self->_render(@_) }
|
||||||
}
|
}
|
||||||
@@ -24,15 +28,23 @@ sub _init {
|
|||||||
|
|
||||||
#$Template::Parser::DEBUG = 1;
|
#$Template::Parser::DEBUG = 1;
|
||||||
|
|
||||||
|
my $dir;
|
||||||
my $app = delete $args{mojo} || delete $args{app};
|
my $app = delete $args{mojo} || delete $args{app};
|
||||||
|
if($dir=$args{cache_dir}) {
|
||||||
|
|
||||||
my $dir = $app && $app->home->rel_dir('tmp/ctpl');
|
if($app && substr($dir,0,1) ne '/') {
|
||||||
|
$dir=$app->home->rel_dir('tmp/ctpl');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
# take and process options :-)
|
# take and process options :-)
|
||||||
|
|
||||||
my %config = (
|
my %config = (
|
||||||
($app ? (INCLUDE_PATH => abs_path($app->home->rel_dir('templates'))) : ()),
|
( $app
|
||||||
|
? (INCLUDE_PATH => (join ":", map { abs_path($_) } @{$app->renderer->paths}))
|
||||||
|
: ()
|
||||||
|
),
|
||||||
COMPILE_EXT => '.ttc',
|
COMPILE_EXT => '.ttc',
|
||||||
COMPILE_DIR => ($dir || abs_path(File::Spec->tmpdir)),
|
COMPILE_DIR => ($dir || abs_path(File::Spec->tmpdir)),
|
||||||
UNICODE => 1,
|
UNICODE => 1,
|
||||||
@@ -43,7 +55,7 @@ sub _init {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$config{LOAD_TEMPLATES} =
|
$config{LOAD_TEMPLATES} =
|
||||||
[MojoX::Renderer::TT::Provider->new(%config, renderer => $app->renderer)]
|
[Mojolicious::Plugin::TtRenderer::Provider->new(%config, renderer => $app->renderer)]
|
||||||
unless $config{LOAD_TEMPLATES};
|
unless $config{LOAD_TEMPLATES};
|
||||||
|
|
||||||
$self->tt(Template->new(\%config))
|
$self->tt(Template->new(\%config))
|
||||||
@@ -64,7 +76,7 @@ sub _render {
|
|||||||
return unless $t;
|
return unless $t;
|
||||||
|
|
||||||
|
|
||||||
my $helper = MojoX::Renderer::TT::Helper->new(ctx => $c);
|
my $helper = Mojolicious::Plugin::TtRenderer::Helper->new(ctx => $c);
|
||||||
|
|
||||||
# Purge previous result
|
# Purge previous result
|
||||||
$$output = '';
|
$$output = '';
|
||||||
@@ -75,25 +87,15 @@ sub _render {
|
|||||||
my $ok = $self->tt->process(defined $inline ? \$inline : $t, @params);
|
my $ok = $self->tt->process(defined $inline ? \$inline : $t, @params);
|
||||||
|
|
||||||
# Error
|
# Error
|
||||||
unless ($ok) {
|
die $self->tt->error unless $ok;
|
||||||
|
|
||||||
my $e = Mojo::Exception->new(
|
|
||||||
$self->tt->error.'',
|
|
||||||
$self->tt->service->process(defined $inline ? \$inline : $t));
|
|
||||||
$$output = '';
|
|
||||||
$c->app->log->error(qq/Template error in "$t": $e/);
|
|
||||||
$c->render_exception($e);
|
|
||||||
$self->tt->error('');
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
1; # End of MojoX::Renderer::TT
|
1; # End of Mojolicious::Plugin::TtRenderer::Engine
|
||||||
|
|
||||||
package
|
package
|
||||||
MojoX::Renderer::TT::Helper;
|
Mojolicious::Plugin::TtRenderer::Helper;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
@@ -123,12 +125,13 @@ sub AUTOLOAD {
|
|||||||
1;
|
1;
|
||||||
|
|
||||||
package
|
package
|
||||||
MojoX::Renderer::TT::Provider;
|
Mojolicious::Plugin::TtRenderer::Provider;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use base 'Template::Provider';
|
use base 'Template::Provider';
|
||||||
|
use Scalar::Util 'weaken';
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
@@ -138,6 +141,7 @@ sub new {
|
|||||||
|
|
||||||
my $self = $class->SUPER::new(%params);
|
my $self = $class->SUPER::new(%params);
|
||||||
$self->renderer($renderer);
|
$self->renderer($renderer);
|
||||||
|
weaken($self->{renderer});
|
||||||
return $self;
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +163,7 @@ sub _template_content {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Try DATA section
|
# Try DATA section
|
||||||
elsif (my $d = $self->renderer->get_inline_template($self->ctx, $t)) {
|
elsif (my $d = $self->renderer->get_data_template($self->ctx, $t)) {
|
||||||
return wantarray ? ($d, '', time) : $d;
|
return wantarray ? ($d, '', time) : $d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +181,7 @@ __END__
|
|||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
MojoX::Renderer::TT - Template Toolkit renderer for Mojo
|
Mojolicious::Plugin::TtRenderer::Engine - Template Toolkit renderer for Mojo
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
@@ -190,9 +194,9 @@ Add the handler:
|
|||||||
$self->plugin(tt_renderer => {template_options => {FILTERS => [ ... ]}});
|
$self->plugin(tt_renderer => {template_options => {FILTERS => [ ... ]}});
|
||||||
|
|
||||||
# Or manually
|
# Or manually
|
||||||
use MojoX::Renderer::TT;
|
use Mojolicious::Plugin::TtRenderer::Engine;
|
||||||
|
|
||||||
my $tt = MojoX::Renderer::TT->build(
|
my $tt = Mojolicious::Plugin::TtRenderer::Engine->build(
|
||||||
mojo => $self,
|
mojo => $self,
|
||||||
template_options => {
|
template_options => {
|
||||||
PROCESS => 'tpl/wrapper',
|
PROCESS => 'tpl/wrapper',
|
||||||
@@ -240,12 +244,17 @@ Supported parameters are
|
|||||||
|
|
||||||
=item mojo
|
=item mojo
|
||||||
C<build> currently uses a C<mojo> parameter pointing to the base class (Mojo).
|
C<build> currently uses a C<mojo> parameter pointing to the base class (Mojo).
|
||||||
object. When used the INCLUDE_PATH will be set to
|
object. When used the INCLUDE_PATH will be set to
|
||||||
|
|
||||||
=item template_options
|
=item template_options
|
||||||
|
|
||||||
A hash reference of options that are passed to Template->new().
|
A hash reference of options that are passed to Template->new().
|
||||||
|
|
||||||
|
=item cache_dir
|
||||||
|
|
||||||
|
Absolute or relative dir to your app home, to cache processed versions of your
|
||||||
|
templates. Will default to a temp-dir if not set.
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
||||||
=head1 AUTHOR
|
=head1 AUTHOR
|
||||||
@@ -255,7 +264,6 @@ Ask Bjørn Hansen, C<< <ask at develooper.com> >>
|
|||||||
=head1 TODO
|
=head1 TODO
|
||||||
|
|
||||||
* Better support non-Mojolicious frameworks
|
* Better support non-Mojolicious frameworks
|
||||||
* Move the default template cache directory?
|
|
||||||
* Better way to pass parameters to the templates? (stash)
|
* Better way to pass parameters to the templates? (stash)
|
||||||
* More sophisticated default search path?
|
* More sophisticated default search path?
|
||||||
|
|
||||||
@@ -271,7 +279,7 @@ make changes.
|
|||||||
|
|
||||||
You can find documentation for this module with the perldoc command.
|
You can find documentation for this module with the perldoc command.
|
||||||
|
|
||||||
perldoc MojoX::Renderer::TT
|
perldoc Mojolicious::Plugin::TtRenderer::Engine
|
||||||
|
|
||||||
You can also look for information at:
|
You can also look for information at:
|
||||||
|
|
||||||
+2
-2
@@ -3,7 +3,7 @@
|
|||||||
use Test::More tests => 1;
|
use Test::More tests => 1;
|
||||||
|
|
||||||
BEGIN {
|
BEGIN {
|
||||||
use_ok( 'MojoX::Renderer::TT' );
|
use_ok( 'Mojolicious::Plugin::TtRenderer::Engine' );
|
||||||
}
|
}
|
||||||
|
|
||||||
diag( "Testing MojoX::Renderer::TT $MojoX::Renderer::TT::VERSION, Perl $], $^X" );
|
diag( "Testing Mojolicious::Plugin::TtRenderer::Engine $Mojolicious::Plugin::TtRenderer::Engine::VERSION, Perl $], $^X" );
|
||||||
|
|||||||
@@ -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 + % %]
|
||||||
+1
-1
@@ -16,7 +16,7 @@ use Test::Mojo;
|
|||||||
# Silence
|
# Silence
|
||||||
app->log->level('fatal');
|
app->log->level('fatal');
|
||||||
|
|
||||||
use_ok('MojoX::Renderer::TT');
|
use_ok('Mojolicious::Plugin::TtRenderer::Engine');
|
||||||
|
|
||||||
plugin 'tt_renderer' => {template_options => {PRE_CHOMP => 1, POST_CHOMP => 1, TRIM => 1}};
|
plugin 'tt_renderer' => {template_options => {PRE_CHOMP => 1, POST_CHOMP => 1, TRIM => 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$}] } );
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
foo
|
||||||
|
[% PROCESS doesnotexist.tt IF do_process %]
|
||||||
|
bar
|
||||||
|
|
||||||
+23
-3
@@ -15,7 +15,7 @@ BEGIN { $ENV{MOJO_TMPDIR} ||= File::Temp::tempdir }
|
|||||||
# Make sure sockets are working
|
# Make sure sockets are working
|
||||||
plan skip_all => 'working sockets required for this test!'
|
plan skip_all => 'working sockets required for this test!'
|
||||||
unless Mojo::IOLoop->new->generate_port;
|
unless Mojo::IOLoop->new->generate_port;
|
||||||
plan tests => 3;
|
plan tests => 6;
|
||||||
|
|
||||||
# Leela: OK, this has gotta stop. I'm going to remind Fry of his humanity the way only a woman can.
|
# Leela: OK, this has gotta stop. I'm going to remind Fry of his humanity the way only a woman can.
|
||||||
# Farnsworth: You're going to do his laundry?
|
# Farnsworth: You're going to do his laundry?
|
||||||
@@ -30,10 +30,30 @@ plugin 'tt_renderer';
|
|||||||
app->log->level('error');
|
app->log->level('error');
|
||||||
|
|
||||||
# GET /
|
# GET /
|
||||||
get '/' => 'index';
|
get '/' => 'index';
|
||||||
|
get '/blow' => sub {
|
||||||
|
shift->render(template => 'conditional-exception', do_process => 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
my $t = Test::Mojo->new;
|
my $t = Test::Mojo->new;
|
||||||
|
|
||||||
# Simple TT template
|
# Simple TT template
|
||||||
$t->get_ok('/')->status_is(200)
|
$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/);
|
||||||
|
|
||||||
|
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