Calling plugin_setting from a plugedin keyword
In Dancer2::Plugin::Passphrase on line 75 I have: my $settings = plugin_setting(); Keyword 'plugin_setting' is exported by Dancer2::Plugin. In an app I can use the keyword 'passphrase' and it's in the dsl. In an other plugin I want to use the 'passphrase' keyword. package Dancer2::Plugin::Peek; # ABSTRACT: Peek around use Dancer2::Plugin; use Data::Peek; sub peekplugin { my ($dsl, @args) = plugin_args(@_); my $phrase = $dsl->passphrase( 'my password' )->generate->rfc2307; $dsl->var(peekphrase => DDumper \$phrase); } register peekplugin => \&peekplugin; register_plugin; 1; __END__ Yes. I can see the generated phrase in a template. But I also get: DEPRECATED: Dancer2::Plugin::Peek calls 'dsl' instead of '$dsl->dsl'. at /usr/local/lib/perl5/site_perl/Dancer2/Plugin/Passphrase.pm line 75. So, the question is: How do I call 'plugin_setting' in a D2 plugin? -- Henk van Oers
On Sun, 8 Mar 2015, Henk van Oers wrote: [...]
So, the question is: How do I call 'plugin_setting' in a D2 plugin?
Found it! Call plugin_setting in an on_plugin_import block. my $settings = {}; on_plugin_import { $settings = plugin_setting() unless $settings->{'_loaded'}; $settings->{'_loaded'} = 1; }; register mykeyword => sub { ... $settings->{'thing'} ... }; ... Now you can call $dsl->mykeyword without the "... calls 'dsl' instead of '$dsl->dsl' ..." warning. -- Henk van Oers
participants (1)
-
Henk van Oers