actually, Sledge does not have real plugin system..
currently, typical plugin codes are below.
write sub import {} and modify symbol tables directly.
package Sledge::Plugin::Foo;
use strict;
sub import {
my $class = shift;
my $pkg = caller;
no strict 'refs';
*{"$pkg\::foo"} = sub {
# do something
};
$pkg->register_hook(
AFTER_DISPATCH => sub {
# do something.
},
);
}
package Sledge::Plugin::Bar;
use strict; use base qw(Sledge::Plugin); __PACKAGE__->add_methods( plugin_method => sub { my $self = shift; # ... }, );
__PACKAGE__->register_hooks( AFTER_DISPATCH => sub { my $self = shift; # ... }, );
package MyApp::Pages::Root; use strict; use base qw(MyApp::Pages::Base); use Sledge::PluginLoader qw(Bar); # load Sledge::Plugin::Bar.
sub dispatch_index { my $self = shift; # You can call the method which provided by plugins. $self->plugin_method; }