1 package TestApp::Controller::Root;
2 use base 'Catalyst::Controller';
3 __PACKAGE__->config(namespace => '');
5 sub default : Private {
8 $c->response->redirect($c->uri_for('test'));
14 $c->stash->{message} = ($c->request->param('message') || $c->config->{default_message});
17 sub test_includepath : Local {
19 $c->stash->{message} = ($c->request->param('message') || $c->config->{default_message});
20 $c->stash->{template} = $c->request->param('template');
21 if ( $c->request->param('additionalpath') ){
22 my $additionalpath = Path::Class::dir($c->config->{root}, $c->request->param('additionalpath'));
23 $c->stash->{additional_template_paths} = ["$additionalpath"];
25 if ( $c->request->param('addpath') ){
26 my $additionalpath = Path::Class::dir($c->config->{root}, $c->request->param('addpath'));
27 my $view = 'TestApp::View::TT::' . ($c->request->param('view') || $c->config->{default_view});
29 push @{$view . '::include_path'}, "$additionalpath";
34 sub test_render : Local {
37 my $out = $c->stash->{message} = $c->view('TT::Appconfig')->render($c, $c->req->param('template'), {param => $c->req->param('param') || ''});
38 if (UNIVERSAL::isa($out, 'Template::Exception')) {
39 $c->response->body($out);
40 $c->response->status(403);
42 $c->stash->{template} = 'test.tt';
47 sub test_msg : Local {
49 my $tmpl = $c->req->param('msg');
51 $c->stash->{message} = $c->view('TT::AppConfig')->render($c, \$tmpl);
52 $c->stash->{template} = 'test.tt';
58 return 1 if $c->response->status =~ /^3\d\d$/;
59 return 1 if $c->response->body;
61 my $view = 'View::TT::' . ($c->request->param('view') || $c->config->{default_view});