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=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..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.05'; +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 => 1 } ); +*paths = \&include_path; =head1 NAME @@ -19,100 +25,736 @@ Catalyst::View::TT - Template View Class =head1 SYNOPSIS - # use the helper - create view TT TT - - # lib/MyApp/View/TT.pm - package MyApp::View::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') ); + } - use base 'Catalyst::View::TT'; +# access variables from template - __PACKAGE__->config->{DEBUG} = 'all'; + The message is: [% message %]. - 1; - - $c->forward('MyApp::View::TT'); + # example when CATALYST_VAR is set to 'Catalyst' + Context is [% Catalyst %] + The base is [% Catalyst.req.base %] + The name is [% Catalyst.config.name %] -=head1 DESCRIPTION + # example when CATALYST_VAR isn't set + Context is [% c %] + The base is [% base %] + The name is [% name %] -This is the C