Cory - sorry about the private email.  That was unintended.  I'm still
getting used to some of the aspects of KMail that I'm not used to.  I'm
reposting it to the list for comments.

On June 25, 2002 11:29 pm, you wrote:
> What about overriding load_tmpl( ) in a sub-class?  I have used this
> method, works very well ... this way, we can pass one filename and let our
> load_tmpl( ) retrieve our
> object (Abstract Factory)  I use this to pass default parameters (and load
> a list of paths
> into the 'path=>' argument to the HTML::Template constructor) and set
> things like 'global_vars' for
> all templates (which I like to do.)

This is all true - I'm overriding load_tmpl for the same purposes
(default variables).  However, I was hoping to take advantage of all
future enhancements to C::A's load_tmpl by calling
$self->SUPER::load_tmpl first.  You mentioned that I could instead pass
in the path when I do this, but I think it's somewhat clumsy when the
base class could reasonably provide this service already, which is what
I would have expected (reasonably, I thought) tmpl_path to do.  If
there wasn't any tmpl_path function, I would have expected to do this
myself.  tmpl_path was added for a very good reason - I was hoping that
it could be taken to the next level of support.

> However, anything I wanted to change this, I could override it at a lower
> level in the class hierarchy, or
> better yet, adapt the HTML::Template's wrapper logic in 'load_tmpl( )' to
> provide whatever additional functionality
> you require.

I don't like copying code that may change, meaning I'd have to make the
same changes to my code as someone else made to the other code.

> -- Cory (not my idea, I stole it from Sam/or/Jesse)

Fair enough :-)

> > -----Original Message-----
> > From: Darin McBride [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, June 25, 2002 10:04 PM
> > To: [EMAIL PROTECTED]
> > Subject: [cgiapp] load_tmpl from multiple paths?
> >
> >
> > I'm attempting to write an application that may one day be translated.
> > In the hopes of this, I'm trying to load my templates from
> > tmpl_path/lang.  However, I also know that not everything will be
> > translated (i.e., new pages that haven't been translated by the
> > volunteer(s)), so I was hoping to use an array to list the template
> > paths.  Unfortunately, when stepping through the load_tmpl function, I
> > notice that I end up with an array ref containing an array ref of
> > paths, which HTML::Template shouldn't be expected to handle.
> >
> > What I'm going to probably do here is make the following patch (I
> > realise this isn't standard patch format, forgive me):
> >
> > The line that says:
> >
> >                             unshift @{$extra_params[$x+1]}, $tmpl_path;
> >
> > will become:
> >
> >                             if (ref($tmpl_path) eq 'ARRAY')
> >                             {
> >                                 unshift @{$extra_params[$x+1]},
> > @$tmpl_path;
> >                             }
> >                             else
> >                             {
> >                                 unshift @{$extra_params[$x+1]},
> > $tmpl_path;
> >                             }
> >
> > and the line that says:
> >
> >         push(@extra_params, path => [ $tmpl_path ]) unless $found;
> >
> > will become:
> >
> >                 unless ($found)
> >                 {
> >                     if (ref($tmpl_path) eq 'ARRAY')
> >                     {
> >                         push @extra_params, path => $tmpl_path;
> >                     }
> >                     else
> >                     {
> >                         push(@extra_params, path => [ $tmpl_path ]);
> >                     }
> >                 }
> >
> > Note that I'm currently using CGI::Application version 2.4.  To use
> > this, I pass in an array ref of paths to tmpl_path(), and this array
> > ref gets passed to HTML::Template::new().
> >
> > Any comments/improvements/concerns/better ideas?  I'm hoping that this
> > patch, or another with similar benefits, will eventually be part of
> > future versions of C::A so I don't have to repatch in the future :-)

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/cgiapp@lists.vm.com/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to