PerlDancer / PerlDancer/Dancer2
Allow setting specific views/layout to AutoPage
Nobody has claimed this yet.
- Dominant language
- Perl
- Stars
- 604
- Forks
- 288
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 5
Description
If you want to mount two applications that will share the same templates and layouts, it's trivial: you just mount them together, they will use the same appdir and it will work.
However, since the paths are now ignoring the mounted bits, you will have to include those in your code:
package MyApp {
use Dancer2;
get '/' => sub { template 'index' => {...} };
}
package MyApp::Extra {
use Dancer2;
get '/' => sub { template 'extra/index' => {...} };
}
# app.pl:
package main {
use MyApp;
use MyApp::Extra;
use Plack::Builder;
builder {
mount '/' => MyApp->to_app;
mount '/extra' => MyApp::Extra->to_app;
};
}
This makes sense because you're basically saying "this application has templates elsewhere in this inner directory."
However, when you're using the AutoPage, it will not know about this special directory, and because it will rightfully ignore the mounting point, you won't be able to render your templates.
You can go nuts and call use MyApp::Extra with => { views => '/path/to/appdir/views/extra' } but it will not use the layout. It will now expect you to provide /path/to/appdir/views/extra/layouts, which makes sense (allowing you to provide multiple views directories across apps in the same appdir.
The way to fix it, IMHO, is to provide another configuration, called auto_page_views, which says "when using AutoPage feature, serve files from this directory". It will look like this:
set auto_page_views => 'extra';
# now AutoPage uses the same layout but the templates come from inside extra/ directory
We can also have auto_page_layout to allow you to make sure AutoPage will always serve with a specific layout.
What do you think?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue does not name implementation files or tests. Start by locating the AutoPage feature and its view/layout configuration, then trace how mounted applications resolve templates and layouts. Done means AutoPage supports separate view and layout configuration such as auto_page_views and auto_page_layout while preserving shared layouts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- perl
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100