On 2004-09-09, Kinyon, Rob <[EMAIL PROTECTED]> wrote:
There's the error_mode change I made. I didn't create a universal diff patch - is this something I need to do in order to get the change added in?
It would be helpful if you have a chance to get oit.
If you rember the thread from just a little bit ago (http://www.mail-archive.com/[EMAIL PROTECTED]/msg02084.html) about tmpl_path and TMPL_PATH only accepting scalar values even though the corresponding H::T 'path' accepts an array ref... Well, I finally got around to making a patch for C::A (including docs and a test) to add this ability in. All test currently pass.
Mark/Jesse - any way this can be incorporated any time soon? any other features/bug/fixes out there for another release?
It sounds reasonable and I'll take a look at it. Send the patch the list
as attachment (unless I already missed it?) and we can get some more
eyeballs on it.
I already sent it with the email that orginated this thread, but I'll send it again...
For the next release, I see these items as likely candidates:
1. better error handling from Rob Kinyon
2. Adding docs to list released plugins and how that system works 3. PATH_INFO support in mode_param
4. adding arrayref support to load_tmpl().
Once I recieve the patches from yourself and Rob, I'll merge everything and post a beta for review.
Looking forward to it :)
-- Michael Peters Developer Plus Three, LP
--- CGI-Application-3.22/lib/CGI/Application.pm 2004-02-13 21:36:57.000000000 -0500 +++ CGI-Application-3.23/lib/CGI/Application.pm 2004-09-08 21:54:21.989399800 -0400 @@ -4,7 +4,7 @@ use Carp; use strict; -$CGI::Application::VERSION = '3.22'; +$CGI::Application::VERSION = '3.23'; ################################### #### INSTANCE SCRIPT METHODS #### @@ -383,18 +383,19 @@ my ($tmpl_file, @extra_params) = @_; # add tmpl_path to path array of one is set, otherwise add a path arg - if (my $tmpl_path = $self->tmpl_path) { + if (my @tmpl_path = $self->tmpl_path) { + @tmpl_path = @{$tmpl_path[0]} if(ref $tmpl_path[0] eq 'ARRAY'); my $found = 0; for( my $x = 0; $x < @extra_params; $x += 2 ) { if ($extra_params[$x] eq 'path' and ref $extra_params[$x+1] and ref $extra_params[$x+1] eq 'ARRAY') { - unshift @{$extra_params[$x+1]}, $tmpl_path; + unshift @{$extra_params[$x+1]}, @tmpl_path; $found = 1; last; } } - push(@extra_params, path => [ $tmpl_path ]) unless $found; + push(@extra_params, path => [ @tmpl_path ]) unless $found; } require HTML::Template; @@ -915,6 +916,7 @@ C<path> option when you call load_tmpl() to get your HTML::Template object. This run-time parameter allows you to further encapsulate instantiating templates, providing potential for more re-usability. +It can be either a scalar or an array reference of multiple paths. PARAMS - This parameter, if used, allows you to set a number of custom parameters at run-time. By passing in different @@ -974,7 +976,7 @@ mode_param() - set the name of the run mode CGI param. start_mode() - text scalar containing the default run mode. run_modes() - hash table containing mode => function mappings. - tmpl_path() - text scalar containing path to template files. + tmpl_path() - text scalar or array refefence containing path(s) to template files. Your setup() method may call any of the instance methods of your application. This function is a good place to define properties specific to your application @@ -1293,7 +1295,7 @@ of HTML::Template. If tmpl_path() has been specified, load_tmpl() will set the -HTML::Template C<path> option to the path provided. This further +HTML::Template C<path> option to the path(s) provided. This further assists in encapsulating template usage. The load_tmpl() method will pass any extra parameters sent to it directly to @@ -1524,9 +1526,10 @@ $webapp->tmpl_path('/path/to/some/templates/'); -This access/mutator method sets the file path to the directory where +This access/mutator method sets the file path to the directory (or directories) where the templates are stored. It is used by load_tmpl() to find the -template files, using HTML::Template's C<path> option. +template files, using HTML::Template's C<path> option. To set the path you can either +pass in a text scalar or an array reference of multiple paths. =back
--- CGI-Application-3.22/t/01cgiapp.t 2004-02-13 21:36:57.000000000 -0500 +++ CGI-Application-3.23/t/01cgiapp.t 2004-09-08 21:44:30.112378784 -0400 @@ -7,7 +7,7 @@ # Change 1..1 below to 1..last_test_to_print . # (It may become useful if the test is moved to ./t subdirectory.) -BEGIN { $| = 1; print "1..26\n"; } +BEGIN { $| = 1; print "1..27\n"; } END {print "not ok 1\n" unless $loaded;} use CGI::Application; $loaded = 1; @@ -523,6 +523,36 @@ print "not ok 26\n"; } } + + +# Test 27: test tmpl_path and load_tmpl to handle an array ref +{ +my $t27_ta_obj = CGI::Application->new(TMPL_PATH => [qw(test/templates /some/other/test/path)]); +my ($t1, $t2) = (0,0); +my $tmpl_path = $t27_ta_obj->tmpl_path(); + +$t1 = 1 if( + (ref $tmpl_path eq 'ARRAY') + && ($tmpl_path->[0] eq 'test/templates') + && ($tmpl_path->[1] eq '/some/other/test/path') + ); + +my $tmpl = $t27_ta_obj->load_tmpl('test.tmpl'); +$tmpl_path = $tmpl->{options}->{path}; + +$t2 = 1 if( + (ref $tmpl_path eq 'ARRAY') + && ($tmpl_path->[0] eq 'test/templates') + && ($tmpl_path->[1] eq '/some/other/test/path') + ); + +if($t1 && $t2) { + print "ok 27\n"; +} else { + print "not ok 27\n"; +} +}
--------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]