X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FView%2FTT.pm;h=5aede35593b3b0f3dc5c8f6c126f53bd7453e0d7;hb=93f25382d55dba60d047409eca5f1ada06ef3f56;hp=934ab6a5b9656ee99a5fee6072db24e74c9e6af4;hpb=8077080cf3b7ce19c6604817d7687352790e77e4;p=catagits%2FCatalyst-View-TT.git diff --git a/lib/Catalyst/View/TT.pm b/lib/Catalyst/View/TT.pm index 934ab6a..5aede35 100644 --- a/lib/Catalyst/View/TT.pm +++ b/lib/Catalyst/View/TT.pm @@ -1,17 +1,14 @@ 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.05'; +our $VERSION = '0.15'; __PACKAGE__->mk_accessors('template'); -__PACKAGE__->mk_classdata('config'); - -__PACKAGE__->config( { EVAL_PERL => 1 } ); =head1 NAME @@ -19,99 +16,411 @@ 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_SUFFIX => '.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