package Catalyst::View::TT;
use strict;
+use warnings;
+
use base qw/Catalyst::View/;
use Data::Dump 'dump';
use Template;
use Template::Timer;
use MRO::Compat;
-our $VERSION = '0.29';
+our $VERSION = '0.30';
__PACKAGE__->mk_accessors('template');
__PACKAGE__->mk_accessors('include_path');
},
);
-# render view from lib/MyApp.pm or lib/MyApp::C::SomeController.pm
+# 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('MyApp::V::TT');
+ $c->forward('MyApp::View::TT');
}
# access variables from template
$ script/myapp_create.pl view TT TT
-This creates a MyApp::V::TT.pm module in the F<lib> directory (again,
+This creates a MyApp::View::TT.pm module in the F<lib> directory (again,
replacing C<MyApp> with the name of your application) which looks
something like this:
- package FooBar::V::TT;
+ package FooBar::View::TT;
use strict;
use base 'Catalyst::View::TT';
sub end : Private {
my( $self, $c ) = @_;
- $c->forward('MyApp::V::TT');
+ $c->forward('MyApp::View::TT');
}
=head2 CONFIGURATION
first way is to call the C<config()> method in the view subclass. This
happens when the module is first loaded.
- package MyApp::V::TT;
+ package MyApp::View::TT;
use strict;
use base 'Catalyst::View::TT';
- MyApp::V::TT->config({
+ MyApp::View::TT->config({
INCLUDE_PATH => [
MyApp->path_to( 'root', 'templates', 'lib' ),
MyApp->path_to( 'root', 'templates', 'src' ),
MyApp->config({
name => 'MyApp',
root => MyApp->path_to('root'),
- 'V::TT' => {
+ 'View::TT' => {
INCLUDE_PATH => [
MyApp->path_to( 'root', 'templates', 'lib' ),
MyApp->path_to( 'root', 'templates', 'src' ),
sub message : Global {
my ( $self, $c ) = @_;
$c->stash->{template} = 'message.tt2';
- $c->forward('MyApp::V::TT');
+ $c->forward( $c->view('TT') );
}
If a stash item isn't defined, then it instead uses the
my ( $self, $c ) = @_;
$c->stash->{template} = 'message.tt2';
$c->stash->{message} = 'Hello World!';
- $c->forward('MyApp::V::TT');
+ $c->forward( $c->view('TT') );
}
A number of other template variables are also added:
MyApp->config({
name => 'MyApp',
root => MyApp->path_to('root'),
- 'V::TT' => {
+ 'View::TT' => {
CATALYST_VAR => 'Catalyst',
},
});
For example:
- package MyApp::C::Test;
+ package MyApp::Controller::Test;
sub test : Local { .. }
Would by default look for a template in <root>/test/test. If you set TEMPLATE_EXTENSION to '.tt', it will look for
MyApp->config({
name => 'MyApp',
root => MyApp->path_to('root'),
- 'V::TT' => {
+ 'View::TT' => {
PROVIDERS => [
{
name => 'DBI',