X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FView%2FTT.pm;h=11b16afc24f919e8949b9d7a48e30fd6c025de8c;hb=dccfa0ff18a9076652cc5128542e1ea2ffad2740;hp=461ab505c3ea6bef0f9e163761c220396e13aea2;hpb=23042c3c04e3f6b0b75a5be6b1f511985a362834;p=catagits%2FCatalyst-View-TT.git diff --git a/lib/Catalyst/View/TT.pm b/lib/Catalyst/View/TT.pm index 461ab50..11b16af 100644 --- a/lib/Catalyst/View/TT.pm +++ b/lib/Catalyst/View/TT.pm @@ -6,7 +6,7 @@ use Template; use Template::Timer; use NEXT; -our $VERSION = '0.12'; +our $VERSION = '0.14'; __PACKAGE__->mk_accessors('template'); @@ -16,45 +16,218 @@ Catalyst::View::TT - Template View Class =head1 SYNOPSIS - # use the helper - create.pl view TT TT +# use the helper to create View + myapp_create.pl view TT TT + +# configure in lib/MyApp.pm + + our $ROOT = '/home/dent/catalyst/MyApp'; + + MyApp->config({ + name => 'MyApp', + root => $ROOT, + 'MyApp::V::TT' => { + # any TT configurations items go here + INCLUDE_PATH => [ + "$ROOT/templates/src", + "$ROOT/templates/lib" + ], + PRE_PROCESS => 'config/main', + WRAPPER => 'site/wrapper', + + # 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