r1416 - in packages/libcgi-application-perl/trunk: . debian lib/CGI

Jaldhar H. Vyas jaldhar at costa.debian.org
Wed Oct 12 21:43:32 UTC 2005


Author: jaldhar
Date: 2005-10-12 21:43:31 +0000 (Wed, 12 Oct 2005)
New Revision: 1416

Modified:
   packages/libcgi-application-perl/trunk/Changes
   packages/libcgi-application-perl/trunk/META.yml
   packages/libcgi-application-perl/trunk/debian/changelog
   packages/libcgi-application-perl/trunk/lib/CGI/Application.pm
Log:
upgraded to 4.04


Modified: packages/libcgi-application-perl/trunk/Changes
===================================================================
--- packages/libcgi-application-perl/trunk/Changes	2005-10-12 21:35:27 UTC (rev 1415)
+++ packages/libcgi-application-perl/trunk/Changes	2005-10-12 21:43:31 UTC (rev 1416)
@@ -1,7 +1,26 @@
 Revision history for Perl extension CGI::Application.
 
+4.04    Wed Oct 11, 2005
+    - No code changes since 4.04_02. Declaring stable. 
+
+4.04_02 Thu Sep 8, 2005 
+    - Add support for templates stored in file handles and scalarrefs to load_tmpl(). 
+      (Jason Purdy)  
+
+4.04_01 Wed Aug 31, 2005
+    -  move load_tmpl hook to after we build $tmpl_file so it will always have a
+      (probably) valid file to work with.
+
+    - initial support for a default template name in load_tmpl(). That means
+      you can now do this:
+
+      my $t = $self->load_tmpl();
+
+      And it will default to a file named after the current run mode with a
+      .html extension. 
+
 4.03  Thu Aug 04, 2005
-    - Fixed important bug introducted in 4.02 in which a mode_param
+    - Fixed important bug introduced in 4.02 in which a mode_param
       set in a sub-class would have been ignored. A new automated test
       was added to prevent this regression in the future. 
 

Modified: packages/libcgi-application-perl/trunk/META.yml
===================================================================
--- packages/libcgi-application-perl/trunk/META.yml	2005-10-12 21:35:27 UTC (rev 1415)
+++ packages/libcgi-application-perl/trunk/META.yml	2005-10-12 21:43:31 UTC (rev 1416)
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name: CGI-Application
-version: 4.03
+version: 4.04
 author:
   - Jesse Erlbaum <jesse at erlbaum.net>
 abstract: Framework for building reusable web-applications
@@ -14,7 +14,7 @@
 provides:
   CGI::Application:
     file: lib/CGI/Application.pm
-    version: 4.03
+    version: 4.04
   CGI::Application::Mailform:
     file: lib/CGI/Application/Mailform.pm
 generated_by: Module::Build version 0.2611

Modified: packages/libcgi-application-perl/trunk/debian/changelog
===================================================================
--- packages/libcgi-application-perl/trunk/debian/changelog	2005-10-12 21:35:27 UTC (rev 1415)
+++ packages/libcgi-application-perl/trunk/debian/changelog	2005-10-12 21:43:31 UTC (rev 1416)
@@ -1,3 +1,9 @@
+libcgi-application-perl (4.04-1) UNRELEASED; urgency=low
+
+  * New upstream release
+
+ -- Jaldhar H. Vyas <jaldhar at debian.org>  Wed, 12 Oct 2005 17:36:09 -0400
+
 libcgi-application-perl (4.03-1) unstable; urgency=low
 
   * New upstream release (Closes: #329498)

Modified: packages/libcgi-application-perl/trunk/lib/CGI/Application.pm
===================================================================
--- packages/libcgi-application-perl/trunk/lib/CGI/Application.pm	2005-10-12 21:35:27 UTC (rev 1415)
+++ packages/libcgi-application-perl/trunk/lib/CGI/Application.pm	2005-10-12 21:43:31 UTC (rev 1416)
@@ -3,7 +3,7 @@
 use strict;
 use Class::ISA;
 
-$CGI::Application::VERSION = '4.03';
+$CGI::Application::VERSION = '4.04';
 
 my %INSTALLED_CALLBACKS = (
 #	hook name          package                 sub
@@ -604,6 +604,9 @@
 
 
 # Make all hash keys CAPITAL
+# although this method is internal, some other extensions
+# have come to rely on it, so any changes here should be
+# made with great care or avoided. 
 sub _cap_hash {
 	my $self = shift;
 	my $rhash = shift;
@@ -1324,13 +1327,27 @@
 
 =item load_tmpl()
 
-    my $tmpl_obj = $webapp->load_tmpl('some.tmpl');
+    my $tmpl_obj = $webapp->load_tmpl;
+    my $tmpl_obj = $webapp->load_tmpl('some.html');
+    my $tmpl_obj = $webapp->load_tmpl( \$template_content );
+    my $tmpl_obj = $webapp->load_tmpl( FILEHANDLE );
 
-This method takes the name of a template file and returns an
-HTML::Template object.  ( For integration with other template systems
+This method takes the name of a template file, a reference to template data
+or a FILEHANDLE and returns an HTML::Template object. If the filename is undefined or missing, CGI::Application will default to trying to use the current run mode name, plus the extension ".html". 
+
+If you use the default template naming system, you should also use
+L<CGI::Application::Plugin::Forward>, which simply helps to keep the current
+name accurate when you pass control from one run mode to another.
+
+( For integration with other template systems
 and automated template names, see "Alternatives to load_tmpl() below. )
 
-The HTML::Template->new_file() constructor is used for create the object.
+When you pass in a filename, the HTML::Template->new_file() constructor
+is used for create the object.  When you pass in a reference to the template
+content, the HTML::Template->new_scalar_ref() constructor is used and
+when you pass in a filehandle, the HTML::Template->new_filehandle()
+constructor is used.
+
 Refer to L<HTML::Template> for specific usage of HTML::Template.
 
 If tmpl_path() has been specified, load_tmpl() will set the
@@ -1338,14 +1355,22 @@
 assists in encapsulating template usage.
 
 The load_tmpl() method will pass any extra parameters sent to it directly to
-HTML::Template->new_file().  This will allow the HTML::Template object to be
-further customized:
+HTML::Template->new_file() (or new_scalar_ref() or new_filehandle()).
+This will allow the HTML::Template object to be further customized:
 
-    my $tmpl_obj = $webapp->load_tmpl('some_other.tmpl',
+    my $tmpl_obj = $webapp->load_tmpl('some_other.html',
          die_on_bad_params => 0,
          cache => 1
     );
 
+Note that if you want to pass extra arguments but use the default template
+name, you still need to provide a name of C<undef>:
+
+    my $tmpl_obj = $webapp->load_tmpl(undef',
+         die_on_bad_params => 0,
+         cache => 1
+    );
+
 B<Alternatives to load_tmpl()>
 
 If your application requires more specialized behavior than this, you can
@@ -1412,13 +1437,32 @@
 		push(@extra_params, path => [ @tmpl_paths ]) unless $found;
 	}
 
-    my %tmpl_params;
+    my %tmpl_params = ();
     my %ht_params = @extra_params;
+    %ht_params = () unless keys %ht_params;
 
+    # Define our extension if doesn't already exist;
+    $self->{__CURRENT_TMPL_EXTENSION} = '.html' unless defined $self->{__CURRENT_TMPL_EXTENSION};
+
+    # Define a default templat name based on the current run mode
+    unless (defined $tmpl_file) {
+        $tmpl_file = $self->get_current_runmode . $self->{__CURRENT_TMPL_EXTENSION};    
+    }
+
     $self->call_hook('load_tmpl', \%ht_params, \%tmpl_params, $tmpl_file);
 
     require HTML::Template;
-    my $t = HTML::Template->new_file($tmpl_file, %ht_params);
+    # let's check $tmpl_file and see what kind of parameter it is - we
+    # now support 3 options: scalar (filename), ref to scalar (the
+    # actual html/template content) and reference to FILEHANDLE
+    my $t = undef;
+    if ( ref $tmpl_file eq 'SCALAR' ) {
+        $t = HTML::Template->new_scalar_ref( $tmpl_file, %ht_params );
+    } elsif ( ref $tmpl_file eq 'GLOB' ) {
+        $t = HTML::Template->new_filehandle( $tmpl_file, %ht_params );
+    } else {
+        $t = HTML::Template->new_file($tmpl_file, %ht_params);
+    }
 
     if (keys %tmpl_params) {
         $t->param(%tmpl_params);
@@ -2135,6 +2179,7 @@
 			die "Error executing class callback in $hook stage: $@" if $@;
 		}
 	}
+
 }
 
 =pod




More information about the Pkg-perl-cvs-commits mailing list