[Dancer-users] a couple of questions re. Plugins

Puneet Kishor punk.kish at gmail.com
Sun Nov 13 23:54:17 CET 2011

1. Does a plugin have to reside under Dancer::Plugin::MyPlugin? Or, can it be situated anywhere, like, for example, under app/lib?

2. Is it possible to call a method in the application from within MyPlugin? Here is what I mean --

In my app.pm, I have a method called 

	sub opts {

I typically set a bunch of template options in the above sub routine, and use it like so

	get '/' => sub {
		my $opts = opts();
		template 'index', $opts;

I am creating plugin that automatically generates a web page like so

	return engine('template')->apply_layout($content);

I would like to run `app::opts()`, and pass the $opts to the template from within the plugin. I am at a loss how to do that.

Puneet Kishor

More information about the Dancer-users mailing list