X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FView%2FTT.pm;h=74d538df826ede93d2bcea77f1548f27cb2ceea6;hb=850ee226cc5b8debfe9132828c22e8b6d055fbc1;hp=e9719ce719fe4ad86c6001c65ce74850b7009dc9;hpb=6bf01217563c97c0a3a226f196fbea82b449fbd0;p=catagits%2FCatalyst-View-TT.git diff --git a/lib/Catalyst/View/TT.pm b/lib/Catalyst/View/TT.pm index e9719ce..74d538d 100644 --- a/lib/Catalyst/View/TT.pm +++ b/lib/Catalyst/View/TT.pm @@ -1,17 +1,15 @@ package Catalyst::View::TT; use strict; -use base qw/Catalyst::Base Class::Data::Inheritable/; +use base qw/Catalyst::View/; use Template; use Template::Timer; use NEXT; -our $VERSION = '0.06'; +our $VERSION = '0.20'; __PACKAGE__->mk_accessors('template'); -__PACKAGE__->mk_classdata('config'); - -__PACKAGE__->config( { EVAL_PERL => 0 } ); +__PACKAGE__->mk_accessors('include_path'); =head1 NAME @@ -19,113 +17,481 @@ Catalyst::View::TT - Template View Class =head1 SYNOPSIS - # use the helper - create view TT TT +# use the helper to create View + myapp_create.pl view TT TT + +# configure in lib/MyApp.pm + + MyApp->config({ + name => 'MyApp', + root => MyApp->path_to('root');, + 'V::TT' => { + # any TT configurations items go here + INCLUDE_PATH => [ + MyApp->path_to( 'root', 'src' ), + MyApp->path_to( 'root', 'lib' ), + ], + PRE_PROCESS => 'config/main', + WRAPPER => 'site/wrapper', + TEMPLATE_EXTENSION => '.tt', + + # two optional config items + CATALYST_VAR => 'Catalyst', + TIMER => 1, + }, + }); + +# render view from lib/MyApp.pm or lib/MyApp::C::SomeController.pm + + sub message : Global { + my ( $self, $c ) = @_; + $c->stash->{template} = 'message.tt2'; + $c->stash->{message} = 'Hello World!'; + $c->forward('MyApp::V::TT'); + } - # lib/MyApp/View/TT.pm - package MyApp::View::TT; +# access variables from template - use base 'Catalyst::View::TT'; + The message is: [% message %]. + + # example when CATALYST_VAR is set to 'Catalyst' + Context is [% Catalyst %] + The base is [% Catalyst.req.base %] + The name is [% Catalyst.config.name %] + + # example when CATALYST_VAR isn't set + Context is [% c %] + The base is [% base %] + The name is [% name %] + +=head1 DESCRIPTION + +This is the Catalyst view class for the L