X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FView%2FTT.pm;h=f51331feb31d63673028b778a8e52f9dc0ef7d31;hb=7bd88b6108e3a78197a7a6a436e4e3466eb38571;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..f51331f 100644 --- a/lib/Catalyst/View/TT.pm +++ b/lib/Catalyst/View/TT.pm @@ -1,17 +1,23 @@ package Catalyst::View::TT; use strict; -use base qw/Catalyst::Base Class::Data::Inheritable/; +use warnings; + +use base qw/Catalyst::View/; +use Data::Dump 'dump'; use Template; use Template::Timer; -use NEXT; +use MRO::Compat; +use Scalar::Util qw/blessed weaken/; -our $VERSION = '0.06'; +our $VERSION = '0.36'; +$VERSION = eval $VERSION; __PACKAGE__->mk_accessors('template'); -__PACKAGE__->mk_classdata('config'); +__PACKAGE__->mk_accessors('expose_methods'); +__PACKAGE__->mk_accessors('include_path'); -__PACKAGE__->config( { EVAL_PERL => 0 } ); +*paths = \&include_path; =head1 NAME @@ -19,114 +25,736 @@ Catalyst::View::TT - Template View Class =head1 SYNOPSIS - # use the helper - create view TT TT +# use the helper to create your View + + myapp_create.pl view Web TT + +# add custom configration in View/Web.pm + + __PACKAGE__->config( + # any TT configuration items go here + INCLUDE_PATH => [ + MyApp->path_to( 'root', 'src' ), + MyApp->path_to( 'root', 'lib' ), + ], + TEMPLATE_EXTENSION => '.tt', + CATALYST_VAR => 'c', + TIMER => 0, + # Not set by default + PRE_PROCESS => 'config/main', + WRAPPER => 'site/wrapper', + render_die => 1, # Default for new apps, see render method docs + expose_methods => [qw/method_in_view_class/], + ); + +# render view from lib/MyApp.pm or lib/MyApp::Controller::SomeController.pm + + sub message : Global { + my ( $self, $c ) = @_; + $c->stash->{template} = 'message.tt2'; + $c->stash->{message} = 'Hello World!'; + $c->forward( $c->view('Web') ); + } - # lib/MyApp/View/TT.pm - package MyApp::View::TT; +# access variables from template - use base 'Catalyst::View::TT'; + The message is: [% message %]. - __PACKAGE__->config->{DEBUG} = 'all'; + # example when CATALYST_VAR is set to 'Catalyst' + Context is [% Catalyst %] + The base is [% Catalyst.req.base %] + The name is [% Catalyst.config.name %] - 1; - - $c->forward('MyApp::View::TT'); + # example when CATALYST_VAR isn't set + Context is [% c %] + The base is [% base %] + The name is [% name %] -=head1 DESCRIPTION +=cut -This is the C