[dancer-users] Usage Of Plugins Out Of CPAN

Kadir Beyazlı kadirbeyazli at gmail.com
Thu May 28 18:43:58 BST 2015


Hi John and Andrew,

On Thu, May 28, 2015 at 3:09 AM, John Stoffel <john at stoffel.org> wrote:
>>>>>> "Andrew" == Andrew Beverley <andy at andybev.com> writes:
>
> Andrew> On Tue, 2015-05-26 at 22:09 +0300, Kadir Beyazlı wrote:
>>> return $route_sub->( $dsl, @args )
>>>
>>> is a coderef.
>
> Andrew> But it doesn't necessarily return a coderef, and certainly didn't when I
> Andrew> ran the code myself.
>
>>> But I read another article from following link :
>>> search.cpan.org/dist/Dancer2/lib/Dancer2/Plugin.pm
>>>
>>> and saw that there are simpler ways of writing and calling a plugin.
>>> 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?
>
> This example doesn't seem to be all that useful because it's not
> showing and explaining how things work.  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.  *grin*
>
> Should test.pl really be:
Yes it should be like this. Instead of word Tuesday I used Logout by mistake
>
>     use Dancer2;
>     use lib "lib";
>     use MyDancer2::Plugin::Tuesday;
>
>     get '/' => sub { tuesday; };
>     start;
>

>
> Instead?  What am I missing?
>
The first code was taken from following link and it does not work, I
got error , I tried again

https://metacpan.org/pod/Dancer2::Manual#Writing-a-plugin

Then I found another link for plugins:

https://metacpan.org/pod/Dancer2::Plugins

At this link the example was simpler, and was about Logout. I applied
it to Tuesday example and while copying here I made a mistake

Regarding first code, I got error but perhaps I am using wrongly so it
is better to offer change it after being sure

> John
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users



-- 
Kadir Beyazlı
Computer Engineer
GSM : +90 535 821 50 00


More information about the dancer-users mailing list