On Wed, 2015-05-27 at 20:09 -0400, John Stoffel wrote:
In my opinion, the example at first link is not good because people starting to Dancer2 read this article. I did following and it worked:
package Dancer2::Plugin::Tuesday; use Dancer2::Plugin;
register tuesday => sub { my $dsl = shift; my $app = $dsl->app; my $conf = plugin_setting();
return "today is tuesday"; };
register_plugin; 1;
and called in a simpler way :
#test.pl use Dancer2; use lib "lib";
use MyDancer2::Plugin::Logout;
get '/' => sub { tuesday };
start;
So how the heck does this app know to use Dancer2::Plugin::Tuesday in the first place? It's totally not obvious. And where did MyDancer2::Plugin::Logout come from?
I think the code is a mix between the example in the manual and the changes that Kadir has made to get it to work for himself.
This example doesn't seem to be all that useful because it's not showing and explaining how things work.
The original example is here: https://metacpan.org/pod/Dancer2::Manual#Route-Decorators
We're not all web gods who do this day in and day out for $WORK... so of us are poor mortals with colds who feel fairly dumb right now.
Is the original example in the manual any better? If not, let us know what you think is missing, and I'm sure someone will add it (possibly me!)
Should test.pl really be:
use Dancer2; use lib "lib"; use MyDancer2::Plugin::Tuesday;
get '/' => sub { tuesday; }; start;
Instead?
The one in the Kadir's email, probably yes, but that's different to the one in the actual manual. Andy