use Mojolicious::Lite;
use Test::Mojo;
plugin 'MojoX::Plugin::Hook::BeforeRendered';
get '/' => sub { shift->render(text => 'foo') };
hook 'before_rendered' => sub {
my ($next, $c) = @_;
$c->render(text => 'bar');
};
Test::Mojo->new->get_ok('/');
Throws this error:
t/10_plugin.t ... 1/? Deep recursion on subroutine "Mojolicious::Controller::render" at t/10_plugin.t line 30.
Deep recursion on subroutine "Mojolicious::Plugins::emit_hook" at /usr/local/share/perl/5.14.2/Mojolicious/Controller.pm line 153.
Deep recursion on subroutine "Mojolicious::Plugins::emit_hook" at /usr/local/share/perl/5.14.2/Mojolicious/Controller.pm line 165.
Deep recursion on anonymous subroutine at /usr/local/share/perl/5.14.2/Mojolicious/Controller.pm line 169.
Deep recursion on subroutine "Mojolicious::Plugins::emit_hook" at /home/iankent/github/MojoX-Plugin-Hook-BeforeRendered/lib/MojoX/Plugin/Hook/BeforeRendered.pm line 26.
Deep recursion on anonymous subroutine at /usr/local/share/perl/5.14.2/Mojolicious/Plugins.pm line 10.
Makes sense as a "feature"..... The logic holds up that if you call render in before_rendered then it kicks off another "render" chain which in turn has a before_rendered which runs render which..... etc :p
Not sure if this is a bug or a feature :)
Throws this error: