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" ],
60 $config{CONTEXT} = Template::Timer->new(%config) if $c->debug;
61 $self->template( Template->new( \%config ) );
67 Renders the template specified in $c->stash->{template} or $c->request->match
68 to $c->response->output.
73 my ( $self, $c ) = @_;
74 $c->res->headers->content_type('text/html;charset=utf8');
76 my $name = $c->stash->{template} || $c->req->match;
78 $c->log->debug('No template specified for rendering') if $c->debug;
81 $c->log->debug(qq/Rendering template "$name"/) if $c->debug;
83 $self->template->process(
87 base => $c->req->base,
89 name => $c->config->{name}
95 my $error = $self->template->error;
96 $error = qq/Couldn't render template "$error"/;
97 $c->log->error($error);
100 $c->res->output($output);
106 This allows your view subclass to pass additional settings to the
117 Sebastian Riedel, C<sri@cpan.org>
122 This program is free software, you can redistribute it and/or modify it under
123 the same terms as Perl itself.