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

Re: [cgiapp] Different outputs in H::T and CAP::AnyTemplate


perl 5.6.1
C::A 3.22
H::T 2.7
CAP::AnyTemplate 0.11

Hi Michael,

thank you for your explanations. They sound reasonable for me and you 
convinced me that your solutions is workable.

While testing your pleasant CAP::AnyTemplate I found out another
strange behavior. I extracted it into these 3 files:

===========tmpl.cgi==============
#!/usr/local/bin/perl -w
# instance script, nothing special

use Tmpl;
$ENV{PATH}='/bin:/usr/bin';
my $form = Tmpl->new();
$form->run();
=================================
===========tmpl.tmpl=============
<TMPL_IF NAME=PAR1>
Par1 defined <BR>
</TMPL_IF>

<TMPL_IF NAME=PAR2>
Par2 defined <BR>
</TMPL_IF>
=================================
===========Tmpl.pm=============
package Tmpl;
use base 'CGI::Application';
use CGI::Application::Plugin::AnyTemplate;
use strict;

sub setup {
   my $self = shift;
   $self->start_mode('show_ht');
   $self->run_modes('show_ht'=>'show_ht',
                    'show_at'=>'show_at',
                   );
}

# Load H::T template
sub show_ht {
   my $self = shift;

   my $template = $self->load_tmpl('tmpl.tmpl');

   return $self->tmpl_output($template);

}

# Load CAP::AnyTemplate template
sub show_at {
    my $self = shift;

    $self->template->config(
        default_type => 'HTMLTemplate',
        add_include_paths => '.',
        auto_add_template_extension => 0,
    );

    my $template = $self->template->load('tmpl.tmpl');
    return $self->tmpl_output($template);

}

# Prepare output
sub tmpl_output {
    my $self = shift;
    my $template = shift;


    $template->param("par1", 1);
    my $tmp = $template->output;
    $template->clear_params;
    $template->param("par2", 1);
    return $template->output;
}
1;
=================================

While running http://server/cgi-bin/tmpl.cgi?rm=show_ht I get 
   Par2 defined
as we all suspect. 

But while running http://server/cgi-bin/tmpl.cgi?rm=show_at 
I can see
   Par1 defined
   Par2 defined

It looks like in my configuration AnyTemplates has problems with
clearing parameters after calling $template->output. H::T hasn't such
problems. Is it the case in your environment?

I didn't explored your code, hoping that you will do it yourself much
better and explain/correct this functionality. I believe my example will
help you a little with this task.

Regards,
Wojciech Pietron

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
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.