Hello, >From some previous traffic on this list, Sam Tregar said:
|> Ultimately HTML::Template v2 doesn't offer much in terms of |> official support for sub-classes and extensions. That's a |> deficiency I intend to address in the perpetually-delayed v3. I am trying to create a sub-class of HTML::Template that over-rides the 'param( )' method. The code below "works" -- mostly -- but I have a feeling that I'm doing this all wrong. Does anyone have some advice or a link on HTML::Template v2 sub-classing? I looked at "HTML::Template::Expr" -- my code below is based, roughly, on this module. My major questions are: 1. How does a sub-class of HTML::Template construct itself? Should I over-ride 'new( )' or use something like 'make_new( )' to wrap 'new( )' or 'SUPER::new( )'. 2. What packages should my 'param( )' method be overridden in? More than HTML::Template? The thing that doesn't work right: 1. calls to 'param( )' seem to loose my 'i18n_strings' object -- it isn't ALWAYS present in 'options' when I call 'param( )', just most of the time. I _think_ that this is somehow related to some of the 'param( )' methods I'm using being in the class 'make_new( )' returns, and others, constructed somewhere else, but still using my 'param( )' method. I know that's confusing I haven't slept much in the past few days, sorry. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> package Service::Template; use strict; use vars qw($VERSION); $VERSION = '0.01'; use HTML::Template; use base 'HTML::Template'; sub make_new { my $pkg = shift; my $self; # check hashworthyness croak("Service::Template->new() called with odd number of option parameters - should be of the form option => value") if (@_ % 2); my %options = @_; # create an HTML::Template object, catch the results to keep error # message line-numbers helpful. eval { $self = $pkg->new(%options ); }; croak("Service::Template->new() : Error creating HTML::Template object : $@") if $@; $self->{options}->{i18n_strings} = $options{'i18n_strings'}; return $self; } 1; package HTML::Template; sub param { ... } 1; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ********************************************************************** Confidentiality Notice The information contained in this e-mail is confidential and intended for use only by the person(s) or organization listed in the address. If you have received this communication in error, please contact the sender at O'Neil & Associates, Inc., immediately. Any copying, dissemination, or distribution of this communication, other than by the intended recipient, is strictly prohibited. ********************************************************************** ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Html-template-users mailing list Html-template-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/html-template-users