Is there a version that works with HTML::Template::Pro? I'm using a template system that loads HTML::Template::Pro if available (for the speed enhancements)

Really? Did you do benchmarks and find that your templating was bottleneck? And if so, how much of a gain did you get from HTML::Template::Pro? If page takes 1 sec to create on the server and your templating takes only 10% of your execution time (and I've never had a real page where that was the case, it's usually closer to 2-5%) and you increase the speed of your templating by 25x (that's the max claimed by H::T::P) then you've taken a full 0.096 sec off.

That little gain is just not worth it to me if you have to jump through hoops to make other things with with the module (like you're trying to do with H::T::Sec). Plus it doesn't support query() which I find extremely handy.
I did some performance profiling of H::T some time ago -> it turns out that there is quite a bit of speed up (somewhere between 10% and 10x, depending on the page) by re-writing part of the code located around line 2660.

hope this helps,
Mathew

patch -> replace the options{associate} conditional with this:

 # support the associate magic, searching for undefined params and
 # attempting to fill them from the associated objects.
 if (scalar(@{$options->{associate}})) {
   my @undef_params;
   foreach my $param (keys %{$self->{param_map}}) {
     next if (defined $self->param($param));
     push @undef_params, $param;
   }
   if (scalar(@undef_params)) {
     my $value;
     # if case sensitive mode or no CGI objects, we can use the fast path
if ($options->{case_sensitive} or (grep { !/^1/ } map { UNIVERSAL::isa($_,'HTML::Template') } @{$options->{associate}}) == 0) {
       foreach my $param (@undef_params) {
         foreach my $associated_object (reverse @{$options->{associate}}) {
           $value = $associated_object->param($param);
           next unless (defined $value);
           $self->param($param, scalar $value);
           last;
         }
       }
     } else {
       my %case_map;
       foreach my $associated_object (@{$options->{associate}}) {
map { $case_map{$associated_object}{lc($_)} = $_ } $associated_object->param();
       }
       my $associated_param;
       foreach my $param (@undef_params) {
         foreach my $associated_object (reverse @{$options->{associate}}) {
           $associated_param = $case_map{$associated_object}{$param};
           next unless (defined $associated_param);
           $value = $associated_object->param($associated_param);
           next unless (defined $value);
           $self->param($param, scalar $value);
           last;
         }
       }
     }
   }
 }

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Html-template-users mailing list
Html-template-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to