Revision history for Perl extension Catalyst::View::TT.
+0.07 Sat Mar 04 23:00:00 2005
+ - fixed the bugs produced by draven and the_jester ;)
+
0.06 Fri Mar 04 20:00:00 2005
- new helper api
SYNOPSIS
# use the helper
- create view TT TT
+ create.pl view TT TT
# lib/MyApp/View/TT.pm
package MyApp::View::TT;
$c->forward('MyApp::View::TT');
DESCRIPTION
- This is the "Template" view class.
+ This is the "Template" view class. Your subclass should inherit from
+ this class. If you want to override TT config settings, you can do it
+ there by setting __PACKAGE__->config->{OPTION} as shown in the synopsis.
+ Of interest might be EVAL_PERL, which is disabled by default, and
+ LOAD_TEMPLATES, which is set to use the provider.
- OVERLOADED METHODS
+ If you want to use EVAL perl, add something like this:
+
+ __PACKAGE__->config->{EVAL_PERL} = 1;
+ __PACKAGE__->config->{LOAD_TEMPLATES} = undef;
+
+ METHODS
process
Renders the template specified in $c->stash->{template} or
$c->request->match to $c->response->output.
package Catalyst::View::TT;
use strict;
-use base qw/Catalyst::Base Class::Data::Inheritable/;
+use base qw/Catalyst::Base/;
use Template;
use Template::Timer;
use NEXT;
-our $VERSION = '0.06';
+our $VERSION = '0.07';
__PACKAGE__->mk_accessors('template');
-__PACKAGE__->mk_classdata('config');
-
-__PACKAGE__->config( { EVAL_PERL => 0 } );
=head1 NAME
=head1 SYNOPSIS
# use the helper
- create view TT TT
+ create.pl view TT TT
# lib/MyApp/View/TT.pm
package MyApp::View::TT;
__PACKAGE__->config->{EVAL_PERL} = 1;
__PACKAGE__->config->{LOAD_TEMPLATES} = undef;
-=head2 OVERLOADED METHODS
+=head2 METHODS
=cut
sub new {
- my $class = shift;
- my $c = shift;
- my $self = $class->NEXT::new(@_);
- our ($template, $provider);
+ my $self = shift;
+ my $c = shift;
+ $self = $self->NEXT::new(@_);
my $root = $c->config->{root};
- $provider ||= Template::Provider->new();
- $provider->include_path([ $root, "$root/base" ]);
- my %config= ( LOAD_TEMPLATES => [ $provider ],
- %{ $class->config() },
- INCLUDE_PATH => [ $root, "$root/base" ]
- );
+ my %config = (
+ EVAL_PERL => 0,
+ INCLUDE_PATH => [ $root, "$root/base" ],
+ %{ $class->config() }
+ );
$config{CONTEXT} = Template::Timer->new(%config) if $c->debug;
- $self->template( Template->new(\%config));
+ $self->template( Template->new( \%config ) );
return $self;
}