1 package Catalyst::View::TT;
4 use base qw/Catalyst::Base/;
11 __PACKAGE__->mk_accessors('template');
15 Catalyst::View::TT - Template View Class
22 # lib/MyApp/View/TT.pm
23 package MyApp::View::TT;
25 use base 'Catalyst::View::TT';
27 __PACKAGE__->config->{DEBUG} = 'all';
31 $c->forward('MyApp::View::TT');
35 This is the C<Template> view class. Your subclass should inherit
36 from this class. If you want to override TT config settings, you
37 can do it there by setting __PACKAGE__->config->{OPTION} as shown
38 in the synopsis. Of interest might be EVAL_PERL, which is disabled
39 by default, and LOAD_TEMPLATES, which is set to use the provider.
41 If you want to use EVAL perl, add something like this:
43 __PACKAGE__->config->{EVAL_PERL} = 1;
44 __PACKAGE__->config->{LOAD_TEMPLATES} = undef;
53 $self = $self->NEXT::new(@_);
54 my $root = $c->config->{root};
57 INCLUDE_PATH => [ $root, "$root/base" ],
61 unless ( $c->debug && not exists $config{CONTEXT} ) {
62 $config{CONTEXT} = Template::Timer->new(%config);
65 $self->template( Template->new( \%config ) );
71 Renders the template specified in $c->stash->{template} or $c->request->match
72 to $c->response->output.
77 my ( $self, $c ) = @_;
78 $c->res->headers->content_type('text/html;charset=utf8');
80 my $name = $c->stash->{template} || $c->req->match;
82 $c->log->debug('No template specified for rendering') if $c->debug;
85 $c->log->debug(qq/Rendering template "$name"/) if $c->debug;
87 $self->template->process(
91 base => $c->req->base,
93 name => $c->config->{name}
99 my $error = $self->template->error;
100 $error = qq/Couldn't render template "$error"/;
101 $c->log->error($error);
104 $c->res->output($output);
110 This allows your view subclass to pass additional settings to the
121 Sebastian Riedel, C<sri@cpan.org>
122 Marcus Ramberg, C<mramberg@cpan.org>
126 This program is free software, you can redistribute it and/or modify it under
127 the same terms as Perl itself.