NAME
Dancer::Plugin::Controller - interface between a model and view
SYNOPSIS
# YourApp.pm
use Dancer ':syntax';
use Dancer::Plugin::Controller;
get '/' => sub {
controller(
action => 'Index', # lib/<config:action_prefix>/Index.pm
template => 'index', # views/index.[tt|tpl|...]
layout => 'page_custom_layout', # if you need other than default layout
redirect_404 => '404.html' # redirect to if action method return undef
);
};
# YourApp::Action::Index.pm
sub main {
my ($class, $params) = @_; # $params - contains Dancer::params() and Dancer::vars()
...
return $template_params_hashref;
}
# config.yml
plugins:
"Controller":
# this is prefiix for module with implementation of action
action_prefix: 'MyActionPrefix' # default: 'Action'
AUTHOR
Mikhail N Bogdanov <mbogdanov at cpan.org>