[Dancer-users] idiom for programming the Perl OO way with Dancer

sukria sukria at sukria.net
Tue Aug 3 19:35:36 CEST 2010


On Tue, 3 Aug 2010 09:39:26 -0500, P Kishor <punk.kish at gmail.com> wrote:
[...]
> Is there something like that I can do with Dancer? Can I create a
> sub-class of Dancer, add my custom stuff to it, and then create
> application instances with it and program with it the Perl OO way?
> 

This will be possible when the refactoring I'm working on is done.

You'll then be able to do multiple "Dancer::App" instances and mount them
as you like. For instance:

# lib/YourApp/Slideshow.pm
package YourApp::Slideshow;
use Dancer 'syntax';

get '/' => sub { "the root of the slideshow app" };

# you can have as many as you like

# then in your starter script, like YourApp.pm
package YourApp;
use Dancer ':syntax';

load_app 'YourApp::Slideshow', prefix => '/slideshow';

dance;

It's not OO, I know, but that's the way Dancer goes: a DSL way. I hope
that fits your needs.

PS: I'm actively working on that refactoring branch all the week, I hope
it will be finished before our Hackaton schedulded for the 14th of
august...

Regards,


More information about the Dancer-users mailing list