1 package Catalyst::View::TT;
4 use base qw/Catalyst::Base Class::Data::Inheritable/;
11 __PACKAGE__->mk_accessors('template');
12 __PACKAGE__->mk_classdata('config');
14 __PACKAGE__->config( { EVAL_PERL => 1 } );
18 Catalyst::View::TT - Template View Class
25 # lib/MyApp/View/TT.pm
26 package MyApp::View::TT;
28 use base 'Catalyst::View::TT';
30 __PACKAGE__->config->{DEBUG} = 'all';
34 $c->forward('MyApp::View::TT');
38 This is the C<Template> view class.
40 =head2 OVERLOADED METHODS
47 my $self = $class->NEXT::new(@_);
48 my $root = $c->config->{root};
50 ( %{ $class->config }, INCLUDE_PATH => [ $root, "$root/base" ] );
51 $config{CONTEXT} = Template::Timer->new(%config) if $c->debug;
52 $self->template( Template->new( \%config ) );
58 Renders the template specified in $c->stash->{template} or $c->request->match
59 to $c->response->output.
64 my ( $self, $c ) = @_;
65 $c->res->headers->content_type('text/html;charset=utf8');
67 my $name = $c->stash->{template} || $c->req->match;
69 $c->log->debug('No template specified for rendering') if $c->debug;
72 $c->log->debug(qq/Rendering template "$name"/) if $c->debug;
74 $self->template->process(
78 base => $c->req->base,
80 name => $c->config->{name}
86 my $error = $self->template->error;
87 $error = qq/Couldn't render template "$error"/;
88 $c->log->error($error);
91 $c->res->output($output);
97 This allows your view subclass to pass additional settings to the
108 Sebastian Riedel, C<sri@cpan.org>
113 This program is free software, you can redistribute it and/or modify it under
114 the same terms as Perl itself.