plugin_setting function
Hi All, I am studying plugins so I am reading manual from cpan (thanks to sawyer) and testing all codes at my pc. I did not get any result by calling function plugin_setting() my code to test calling plugin (test.pl) and plugin code (MyTest.pm) is written below: -------------------------------------------------------------------------------------------------- #test.pl use Dancer2; use lib "../lib/"; use Dancer2::Plugin::MyTest; get '/mytest' => sub { mytest('I am Testing') }; dance(); ---------------------------------------------------------------------------------------------------- #MyTest.pm package Dancer2::Plugin::MyTest; use Dancer2::Plugin; register mytest => sub { my ($dsl, @args) = plugin_args(@_); my $conf = plugin_setting(); use Data::Dumper; return Dumper($conf); }; register_plugin for_versions => [ 2 ] ; 1; ----------------------------------------------------------------------------------------------------------------------------------- I added following code to config.yml ----------------------------------------------------------------------------------------------------------------------------------- #config.yml plugins: "Dancer2::Plugin::MyTest": key: value ----------------------------------------------------------------------------------------------------------------------------------- Output of my code which is also output of function plugin_setting() is empty as follow: $VAR1 = {}; I changed config.yml as follow but output is empty again ----------------------------------------------------------------------------------------------------------------------------------- #config.yml plugins: "MyTest: key: value ----------------------------------------------------------------------------------------------------------------------------------- How should I customize config.yml file to be able to see output and what is aim of function plugin_setting()? Kadir Beyazlı GSM : +90 535 821 50 00
Hi, I understood logic of plugin_setting() function. It is used to define some configurations to plugin. But I am still getting empty output from function plugin_setting() althouh I set it at config.yml By the way my plugin code is at following folder (mywebapp is root folder) mywebapp/lib/Dancer2/Plugin/MyTest.pm test.pl is at following folder mywebapp/bin/test.pl On Tue, Jun 30, 2015 at 12:58 AM, Kadir Beyazlı <kadirbeyazli@gmail.com> wrote:
Hi All,
I am studying plugins so I am reading manual from cpan (thanks to sawyer) and testing all codes at my pc. I did not get any result by calling function plugin_setting()
my code to test calling plugin (test.pl) and plugin code (MyTest.pm) is written below:
-------------------------------------------------------------------------------------------------- #test.pl use Dancer2;
use lib "../lib/"; use Dancer2::Plugin::MyTest;
get '/mytest' => sub { mytest('I am Testing') };
dance(); ---------------------------------------------------------------------------------------------------- #MyTest.pm package Dancer2::Plugin::MyTest; use Dancer2::Plugin;
register mytest => sub { my ($dsl, @args) = plugin_args(@_); my $conf = plugin_setting();
use Data::Dumper; return Dumper($conf); };
register_plugin for_versions => [ 2 ] ;
1; -----------------------------------------------------------------------------------------------------------------------------------
I added following code to config.yml
----------------------------------------------------------------------------------------------------------------------------------- #config.yml plugins: "Dancer2::Plugin::MyTest": key: value -----------------------------------------------------------------------------------------------------------------------------------
Output of my code which is also output of function plugin_setting() is empty as follow:
$VAR1 = {};
I changed config.yml as follow but output is empty again
----------------------------------------------------------------------------------------------------------------------------------- #config.yml plugins: "MyTest: key: value -----------------------------------------------------------------------------------------------------------------------------------
How should I customize config.yml file to be able to see output and what is aim of function plugin_setting()?
Kadir Beyazlı GSM : +90 535 821 50 00
-- Kadir Beyazlı Computer Engineer GSM : +90 535 821 50 00
On Tue, 2015-06-30 at 00:58 +0300, Kadir Beyazlı wrote:
my code to test calling plugin (test.pl) and plugin code (MyTest.pm) is written below:
[...] Your code works for me.
#config.yml plugins: "MyTest: key: value
As long as you are using this config file not your other one (with Dancer2::Plugin::MyTest as the key). Are you sure your config file is being read and that the YAML is formatted correctly? Andy
Hi Andrew, On Tue, Jun 30, 2015 at 11:42 AM, Andrew Beverley <andy@andybev.com> wrote:
On Tue, 2015-06-30 at 00:58 +0300, Kadir Beyazlı wrote:
my code to test calling plugin (test.pl) and plugin code (MyTest.pm) is written below:
[...]
Your code works for me.
#config.yml plugins: "MyTest: key: value
As long as you are using this config file not your other one (with Dancer2::Plugin::MyTest as the key).
Are you sure your config file is being read and that the YAML is formatted correctly?
[KB] There is no problem at YAML format. I saw what I expected when I changed path of test.pl file It was at following folder. mywebapp/bin/test.pl I moved it to following folder: mywebapp/test.pl I edited 'lib' info as follow to be able to reach Dancer2::Plugin::MyTest; use lib "lib"; use Dancer2::Plugin::MyTest; As a result, YAML file is not accessible or readable unless I put it to folder mywebapp/. As I remember, it was said that the best place to put .pl file was mywebapp/bin directory so I put there firstly
Andy
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
-- Kadir Beyazlı Computer Engineer GSM : +90 535 821 50 00
participants (2)
-
Andrew Beverley -
Kadir Beyazlı