[Catalyst] Best practice: How to build app parts reusable?
Iain
iainhubbard at googlemail.com
Tue Jun 2 09:51:12 GMT 2009
On Tue, 2009-06-02 at 11:05 +0200, Zbigniew Lukasiak wrote:
> Just one idea - in the TT view there is a
> http://search.cpan.org/~mramberg/Catalyst-View-TT-0.29/lib/Catalyst/View/TT.pm#DYNAMIC_INCLUDE_PATH
> option.
This is exactly what we used in this situation, as mentioned before we
have wrapper classes with use lib/base to get at the shared code and
then in the shared base controller we setup the alternate TT search
paths.
sub apath : Chained('/') : CaptureArgs(0) {
my ( $self, $c ) = @_;
$c->stash->{'additional_template_paths'} =
['/path/to/shared/templates'];
return 1;
}
The good thing about this for us is that we can override the path in the
child controller.
sub apath : PathPart('different/path') Chained('/') CaptureArgs(0) {
my ( $self, $c ) = @_;
$self->NEXT::apath($c);
}
This has allowed us to have the same code for a number of sites with
different urls and site specific stuff kept in the respective child
controllers.
Iain.
More information about the Catalyst
mailing list