On Fri, 20 Aug 2010 06:32:54 -0500, P Kishor <punk.kish@gmail.com> wrote: [...]
app/ environments/ view/ lib/ public/ t/
The above works well for a relatively simple application, but if I have several groups of relatively complicated functions, I would like to group them by, well, by functions. Here is what I would like --
app/ function1/ function2/
function1 and function2 would be like mini dancer apps in their own right, but would share common resources such as top menu, login capabilities, logos, images (common to the both of them), master style sheet, etc. They would likely also share a fair bit of common Perl code, and also some data tables from a db.
What is a suggested pattern for that?
This is where you really should upgrade to 1.1806_02, in order to benefit from the 'load_app' feature. You'll be able to do the following: appdir/ yourapp.pl lib/ yourapp.pm yourapp/ function1.pm function2.pm views/ function1/ function2/ in yourapp.pm, you mount your subapps like that package yourapp; use Dancer ':syntax'; load_app 'yourapp::function1', prefix => '/function1'; load_app 'yourapp::function2', prefix => '/function2'; ... and in your subapps: package yourapp::function1; use Dancer ':syntax'; get '/' => sub { "root of function1" }; ...