import of last CPAN release.
[catagits/Catalyst-View-TT.git] / README
diff --git a/README b/README
index 3e5f036..d2dcc37 100644 (file)
--- a/README
+++ b/README
@@ -6,19 +6,18 @@ SYNOPSIS
 
     # configure in lib/MyApp.pm
 
-        our $ROOT = '/home/dent/catalyst/MyApp';
-
         MyApp->config({
             name     => 'MyApp',
-            root     => $ROOT,
-            'MyApp::V::TT' => {
+            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', 'src' ), 
+                  MyApp->path_to( 'root', 'lib' ), 
                 ],
-                PRE_PROCESS => 'config/main',
-                WRAPPER     => 'site/wrapper',
+                PRE_PROCESS        => 'config/main',
+                WRAPPER            => 'site/wrapper',
+                TEMPLATE_EXTENSION => '.tt',
 
                 # two optional config items
                 CATALYST_VAR => 'Catalyst',
@@ -91,10 +90,11 @@ DESCRIPTION
         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',
         });
@@ -108,7 +108,10 @@ DESCRIPTION
         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',
             });
@@ -127,13 +130,14 @@ DESCRIPTION
         use strict;
         use Catalyst;
     
-        our $ROOT = '/home/dent/catalyst/MyApp';
-    
         MyApp->config({
             name     => 'MyApp',
-            root     => $ROOT,
-            'MyApp::V::TT' => {
-                INCLUDE_PATH => ["$ROOT/templates/src", "$ROOT/templates/lib"],
+            root     => MyApp->path_to('root'),
+            'V::TT' => {
+                INCLUDE_PATH => [
+                    MyApp->path_to( 'root', 'templates', 'lib' ),
+                    MyApp->path_to( 'root', 'templates', 'src' ),
+                ],
                 PRE_PROCESS  => 'config/main',
                 WRAPPER      => 'site/wrapper',
             },
@@ -143,6 +147,14 @@ DESCRIPTION
     will be overwritten by items of the same name provided by the latter
     methods.
 
+  DYNAMIC INCLUDE_PATH
+    It is sometimes needed to dynamically add additional paths to the
+    INCLUDE_PATH variable of the template object. This can be done by
+    setting 'additional_include_paths' on stash to a referrence to an array
+    with additional paths:
+
+        $c->stash->{additional_template_paths} = [$c->config->{root} . '/test_include_path']; 
+
   RENDERING VIEWS
     The view plugin renders the template specified in the "template" item in
     the stash.
@@ -178,51 +190,10 @@ DESCRIPTION
         The base is [% base %]
         The name is [% name %]
 
-    If you prefer, you can set the "CATALYST_VAR" configuration item to
-    define the name of a template variable through which the context can be
-    referenced.
-
-        MyApp->config({
-            name     => 'MyApp',
-            root     => $ROOT,
-            'MyApp::V::TT' => {
-                CATALYST_VAR => 'Catalyst',
-            },
-        });
-
-    message.tt2:
-
-        The base is [% Catalyst.req.base %]
-        The name is [% Catalyst.config.name %]
-
     The output generated by the template is stored in
     "$c->response->output".
 
   TEMPLATE PROFILING
-    If you have configured Catalyst for debug output, "Catalyst::View::TT"
-    will enable profiling of template processing (using Template::Timer).
-    This will embed HTML comments in the output from your templates, such
-    as:
-
-        <!-- TIMER START: process mainmenu/mainmenu.ttml -->
-        <!-- TIMER START: include mainmenu/cssindex.tt -->
-        <!-- TIMER START: process mainmenu/cssindex.tt -->
-        <!-- TIMER END: process mainmenu/cssindex.tt (0.017279 seconds) -->
-        <!-- TIMER END: include mainmenu/cssindex.tt (0.017401 seconds) -->
-
-        ....
-
-        <!-- TIMER END: process mainmenu/footer.tt (0.003016 seconds) -->
-
-    You can suppress template profiling by setting the "TIMER" configuration
-    item to a false value.
-
-        MyApp->config({
-            'MyApp::V::TT' => {
-                TIMER => 0,
-            },
-        });
-
   METHODS
     new The constructor for the TT view. Sets up the template provider, and
         reads the application config.
@@ -240,8 +211,56 @@ DESCRIPTION
 
     config
         This method allows your view subclass to pass additional settings to
-        the TT configuration hash, or to set the "CATALYST_VAR" and "TIMER"
-        options.
+        the TT configuration hash, or to set the options as below:
+
+        "CATALYST_VAR"
+          Allows you to change the name of the Catalyst context object. If
+          set, it will also remove the base and name aliases, so you will
+          have access them through <context>.
+
+          For example:
+
+              MyApp->config({
+                  name     => 'MyApp',
+                  root     => MyApp->path_to('root'),
+                  'V::TT' => {
+                      CATALYST_VAR => 'Catalyst',
+                  },
+              });
+
+          message.tt2:
+
+              The base is [% Catalyst.req.base %]
+              The name is [% Catalyst.config.name %]
+
+        "TIMER"
+          If you have configured Catalyst for debug output, and turned on
+          the TIMER setting, "Catalyst::View::TT" will enable profiling of
+          template processing (using Template::Timer). This will embed HTML
+          comments in the output from your templates, such as:
+
+              <!-- TIMER START: process mainmenu/mainmenu.ttml -->
+              <!-- TIMER START: include mainmenu/cssindex.tt -->
+              <!-- TIMER START: process mainmenu/cssindex.tt -->
+              <!-- TIMER END: process mainmenu/cssindex.tt (0.017279 seconds) -->
+              <!-- TIMER END: include mainmenu/cssindex.tt (0.017401 seconds) -->
+
+              ....
+
+              <!-- TIMER END: process mainmenu/footer.tt (0.003016 seconds) -->
+
+        "TEMPLATE_EXTENSION"
+          a sufix to add when looking for templates bases on the "match"
+          method in Catalyst::Request.
+
+          For example:
+
+            package MyApp::C::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
+          <root>/test/test.tt.
 
   HELPERS
     The Catalyst::Helper::View::TT and Catalyst::Helper::View::TTSite helper