- Added additional_template_paths stash param patch from zby
[catagits/Catalyst-View-TT.git] / t / lib / TestApp.pm
CommitLineData
07571b2f 1package TestApp;
2
3use strict;
4use warnings;
5
6use Catalyst; # qw/-Debug/;
e2bbd784 7use Path::Class;
07571b2f 8
9our $VERSION = '0.01';
10
11__PACKAGE__->config(
12 name => 'TestApp',
13 default_message => 'hi',
14 default_view => 'Pkgconfig',
15 'View::TT::Appconfig' => {
16 PRE_CHOMP => 1,
17 POST_CHOMP => 1,
18 TEMPLATE_EXTENSION => '.tt',
19 },
20);
21
22__PACKAGE__->setup;
23
24sub default : Private {
25 my ($self, $c) = @_;
26
27 $c->response->redirect($c->uri_for('test'));
28}
29
30sub test : Local {
31 my ($self, $c) = @_;
32
33 $c->stash->{message} = ($c->request->param('message') || $c->config->{default_message});
34}
35
e2bbd784 36sub test_includepath : Local {
37 my ($self, $c) = @_;
38 $c->stash->{message} = ($c->request->param('message') || $c->config->{default_message});
39 $c->stash->{template} = $c->request->param('template');
40 if ( $c->request->param('additionalpath') ){
41 my $additionalpath = Path::Class::dir($c->config->{root}, $c->request->param('additionalpath'));
42 $c->stash->{additional_template_paths} = ["$additionalpath"];
43 }
44}
45
07571b2f 46sub end : Private {
47 my ($self, $c) = @_;
48
49 return 1 if $c->response->status =~ /^3\d\d$/;
50 return 1 if $c->response->body;
51
52 my $view = 'View::TT::' . ($c->request->param('view') || $c->config->{default_view});
53 $c->forward($view);
54}
55
561;