Updated Catalyst::View::TT for 5.5
Sebastian Riedel [Mon, 14 Nov 2005 13:29:04 +0000 (13:29 +0000)]
Changes
Makefile.PL
lib/Catalyst/Helper/View/TT.pm
lib/Catalyst/View/TT.pm

diff --git a/Changes b/Changes
index a4cb676..6991808 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,7 @@
 Revision history for Perl extension Catalyst::View::TT.
 
 0.15  - TBR
+        - Updated for Catalyst 5.5
         - Fix docs
         - Added TEMPLATE_SUFFIX config variable 
 
index 0424d8d..cda8013 100644 (file)
@@ -4,7 +4,7 @@ WriteMakefile(
     NAME      => 'Catalyst::View::TT',
     AUTHOR    => 'Sebastian Riedel (sri@oook.de)',
     PREREQ_PM => {
-        Catalyst        => '5.00',
+        Catalyst        => '5.5',
         Template        => 0,
         Template::Timer => 0
     },
index 1b605d3..999b527 100644 (file)
@@ -54,7 +54,7 @@ use base 'Catalyst::View::TT';
 
 =head1 NAME
 
-[% class %] - TT View Component
+[% class %] - Catalyst TT View
 
 =head1 SYNOPSIS
 
@@ -62,7 +62,7 @@ See L<[% app %]>
 
 =head1 DESCRIPTION
 
-TT View Component.
+Catalyst TT View.
 
 =head1 AUTHOR
 
@@ -70,8 +70,8 @@ TT View Component.
 
 =head1 LICENSE
 
-This library is free software . You can redistribute it and/or modify
-it under the same terms as perl itself.
+This library is free software, you can redistribute it and/or modify
+it under the same terms as Perl itself.
 
 =cut
 
index fac246c..2e54829 100644 (file)
@@ -1,7 +1,7 @@
 package Catalyst::View::TT;
 
 use strict;
-use base qw/Catalyst::Base/;
+use base qw/Catalyst::View/;
 use Template;
 use Template::Timer;
 use NEXT;
@@ -21,16 +21,14 @@ Catalyst::View::TT - Template View Class
 
 # configure in lib/MyApp.pm
 
-    our $ROOT = '/home/dent/catalyst/MyApp';
-
     MyApp->config({
         name     => 'MyApp',
-        root     => $ROOT,
+        root     => MyApp->path_to('root');,
         'V::TT' => {
             # any TT configurations items go here
             INCLUDE_PATH => [
-              "$ROOT/templates/src", 
-              "$ROOT/templates/lib"
+              MyApp->path_to( 'root', 'templates', 'src' ), 
+              MyApp->path_to( 'root', 'templates', 'lib' ), 
             ],
             PRE_PROCESS => 'config/main',
             WRAPPER     => 'site/wrapper',
@@ -110,10 +108,11 @@ happens when the module is first loaded.
     use strict;
     use base 'Catalyst::View::TT';
 
-    our $ROOT = '/home/dent/catalyst/MyApp';
-    
     MyApp::V::TT->config({
-        INCLUDE_PATH => ["$ROOT/templates/src", "$ROOT/templates/lib"],
+        INCLUDE_PATH => [
+            MyApp->path_to( 'root', 'templates', 'lib' ),
+            MyApp->path_to( 'root', 'templates', 'src' ),
+        ],
         PRE_PROCESS  => 'config/main',
         WRAPPER      => 'site/wrapper',
     });
@@ -127,7 +126,10 @@ performing any configuration.
     sub new {
         my $self = shift;
         $self->config({
-            INCLUDE_PATH => ["$ROOT/templates/src", "$ROOT/templates/lib"],
+            INCLUDE_PATH => [
+                MyApp->path_to( 'root', 'templates', 'lib' ),
+                MyApp->path_to( 'root', 'templates', 'src' ),
+            ],
             PRE_PROCESS  => 'config/main',
             WRAPPER      => 'site/wrapper',
         });
@@ -147,13 +149,14 @@ subclass).
     use strict;
     use Catalyst;
     
-    our $ROOT = '/home/dent/catalyst/MyApp';
-    
     MyApp->config({
         name     => 'MyApp',
-        root     => $ROOT,
+        root     => MyApp->path_to('root'),
         'V::TT' => {
-            INCLUDE_PATH => ["$ROOT/templates/src", "$ROOT/templates/lib"],
+            INCLUDE_PATH => [
+                MyApp->path_to( 'root', 'templates', 'lib' ),
+                MyApp->path_to( 'root', 'templates', 'src' ),
+            ],
             PRE_PROCESS  => 'config/main',
             WRAPPER      => 'site/wrapper',
         },
@@ -226,9 +229,9 @@ sub new {
     my $root = $c->config->{root};
 
     my $config = {
-        EVAL_PERL    => 0,
+        EVAL_PERL          => 0,
         TEMPLATE_EXTENSION => '',
-        INCLUDE_PATH => [ $root, "$root/base" ],
+        INCLUDE_PATH       => [ $root, "$root/base" ],
         %{ $class->config },
         %{$arguments}
     };
@@ -282,7 +285,8 @@ Output is stored in C<$c-E<gt>response-E<gt>output>.
 sub process {
     my ( $self, $c ) = @_;
 
-    my $template = $c->stash->{template} || $c->request->match . $self->config->{TEMPLATE_EXTENSION};
+    my $template = $c->stash->{template}
+      || $c->request->match . $self->config->{TEMPLATE_EXTENSION};
 
     unless ($template) {
         $c->log->debug('No template specified for rendering') if $c->debug;
@@ -337,7 +341,7 @@ For example:
 
     MyApp->config({
         name     => 'MyApp',
-        root     => $ROOT,
+        root     => MyApp->path_to('root'),
         'V::TT' => {
             CATALYST_VAR => 'Catalyst',
         },