prepared for 0.14
[catagits/Catalyst-View-TT.git] / lib / Catalyst / Helper / View / TTSite.pm
index d63ad41..b73e436 100644 (file)
@@ -12,10 +12,9 @@ sub mk_compclass {
 
 sub mk_templates {
     my ( $self, $helper ) = @_;
-    my $base = $helper->{base};
-    my $tdir = File::Spec->catfile( $base, 'templates' );
-    my $ldir = File::Spec->catfile( $tdir, 'lib' );
-    my $sdir = File::Spec->catfile( $tdir, 'src' );
+    my $base = $helper->{base},;
+    my $ldir = File::Spec->catfile( $base, 'root', 'lib' );
+    my $sdir = File::Spec->catfile( $base, 'root', 'src' );
 
     $helper->mk_dir($ldir);
     $helper->mk_dir($sdir);
@@ -55,18 +54,18 @@ Catalyst::Helper::View::TTSite - Helper for TT view which builds a skeleton web
 # add something like the following to your main application module
 
     sub message : Global {
-        my ($self, $c) = @_;
-        $c->stash->{ template } = 'message.tt2';
-        $c->stash->{ message  } = $c->req->param('message') || 'Hello World';
+        my ( $self, $c ) = @_;
+        $c->stash->{template} = 'message.tt2';
+        $c->stash->{message}  ||= $c->req->param('message') || 'No message';
     }
     
     sub default : Private {
-        my ($self, $c) = @_;
-        $c->stash->{ template } = 'welcome.tt2';
+        my ( $self, $c ) = @_;
+        $c->stash->{template} = 'welcome.tt2';
     }
     
     sub end : Private {
-        my ($self, $c) = @_;
+        my ( $self, $c ) = @_;
         $c->forward('MyApp::V::TT');
     }
 
@@ -122,22 +121,17 @@ package [% class %];
 
 use strict;
 use base 'Catalyst::View::TT';
-use NEXT;
 
-sub new {
-    my $self = shift;
-    my $c    = shift;
-    my $root     = $c->config->{ root };
-    my $template = $c->config->{ template } || { };
+my $root = [% app %]->config->{root};
 
-    $template->{ CATALYST_VAR } ||= 'Catalyst',
-    $template->{ INCLUDE_PATH } ||= [ "$root/templates/src", "$root/templates/lib" ];
-    $template->{ PRE_PROCESS  } ||= 'config/main';
-    $template->{ WRAPPER      } ||= 'site/wrapper';
-    $template->{ ERROR        } ||= 'error.tt2';
-
-    return $self->NEXT::new($c, @_);
-}
+__PACKAGE__->config({
+    CATALYST_VAR => 'Catalyst',
+    INCLUDE_PATH => [ "$root/src", "$root/lib" ],
+    PRE_PROCESS  => 'config/main',
+    WRAPPER      => 'site/wrapper',
+    ERROR        => 'error.tt2',
+    TIMER        => 0
+});
 
 =head1 NAME
 
@@ -232,10 +226,10 @@ __config_url__
 __site_wrapper__
 [% TAGS star -%]
 [% IF template.name.match('\.(css|js|txt)');
-     debug("passing page through as text: $template.name");
+     debug("Passing page through as text: $template.name");
      content;
    ELSE;
-     debug("applying HTML page layout wrappers to $template.name\n");
+     debug("Applying HTML page layout wrappers to $template.name\n");
      content WRAPPER site/html + site/layout;
    END;
 -%]