[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cgiapp] PATCH: extra parameter passing support for CGI::Application::Generator 1.0


Hello,

The following patch to CGI::Application::Generator 1.0 allows you to
pass extra parameters to the HTML::Template "new" constructor, or
directly to the "param" call. I did this to set "die_on_bad_params=>0".  
This allowed me to use the same Generator script to allow fill out a
template for my instance script, which just needs the package name, but
not all the other variables.

	Mark

--
http://mark.stosberg.com/ 

####

--- /usr/local/lib/perl5/site_perl/5.8.0/CGI/Application/Generator.pm   Wed Feb 12 23:50:29 2003
+++ Generator.pm        Mon May 19 19:06:11 2003
@@ -409,15 +409,25 @@
   print OUTPUT $c->output_app_module();
   close(OUTPUT);

+You can also pass two optional parameters to this method, each
+as a hash reference. The first is passed as additional parameters
+to the HTML::Template constructor. The second is additional
+name/value pairs to pass directly to HTML::Template's
+param() method.
+
 =cut

 sub output_app_module {
        my $self = shift;
+       my $extra_new_params = shift || {};
+       my $extra_tmpl_params = shift || {};
+

        my $t = HTML::Template->new_file(
                $self->app_module_tmpl(),
                global_vars => 1,
                path => suppressed,
+               %$extra_new_params,
        );

        $t->param(
@@ -428,6 +438,7 @@
                use_modules => [ map { {module_name=>$_} } ($self->use_modules()) ],
                tmpl_path => $self->tmpl_path(),
                new_dbh_method => $self->new_dbh_method(),
+               %$extra_tmpl_params,
        );

        return $t->output()


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.