[cgiapp] [patch] CAP::MessageStack + CAP::FormState
Alex
capfan at gmx.de
Mon Oct 19 17:47:03 EDT 2009
Hi!
I had a quick look at the source of CAP::TT. In contrast to my previous
assumption, you use Template 2.0. So you should set tmpl_class to Template -
if you want to.
I don't get exactly what your import method does, as I'm not very familiar
with all that import and plugin stuff.
Here it is (original), v. 1.04
[code]
sub import {
my $pkg = shift;
my $callpkg = caller;
no strict 'refs';
foreach my $sym (@EXPORT) {
*{"${callpkg}::$sym"} = \&{$sym};
}
$callpkg->tt_config(@_) if @_;
if ($callpkg->isa('CGI::Application')) {
$callpkg->new_hook('tt_pre_process');
$callpkg->new_hook('tt_post_process');
} else {
warn "Calling package is not a CGI::Application module so not
installing tt_pre_process and tt_post_process hooks. If you are using \@ISA
instead of 'use base', make sure it is in a BEGIN { } block, and make sure
these statements appear before the plugin is loaded";
}
}
[/code]
E.g. I don't know why you are using that "no strict refs" and the loop
afterwards. But then you do the configuration and declare the hooks for
classes, that are based on CGI::Application.
This is the part, where I think, you could set up the tmpl_class.
[code]
sub import {
my $pkg = shift;
my $callpkg = caller;
no strict 'refs';
foreach my $sym (@EXPORT) {
*{"${callpkg}::$sym"} = \&{$sym};
}
$callpkg->tt_config(@_) if @_;
$callpkg->html_tmpl_class('Template'); # << here
if ($callpkg->isa('CGI::Application')) {
$callpkg->new_hook('tt_pre_process');
$callpkg->new_hook('tt_post_process');
} else {
warn "Calling package is not a CGI::Application module so not
installing tt_pre_process and tt_post_process hooks. If you are using \@ISA
instead of 'use base', make sure it is in a BEGIN { } block, and make sure
these statements appear before the plugin is loaded";
}
}
[/code]
HTH, Alex
-----Ursprüngliche Nachricht-----
Von: cgiapp-bounces at lists.openlib.org
[mailto:cgiapp-bounces at lists.openlib.org] Im Auftrag von Cees Hek
Gesendet: Montag, 19. Oktober 2009 23:00
An: CGI Application
Betreff: Re: [cgiapp] [patch] CAP::MessageStack + CAP::FormState
On Tue, Oct 20, 2009 at 12:51 AM, Michael Graham <magog at the-wire.com> wrote:
>
> We should be able to detect the use of HTML::Template with
> $self->tmpl_class.
>
> BUT, both CAP::TT and CAP::AnyTemplate call the load_tmpl hook, and
> neither of them sets $self->tmpl_class(). There may be other
> templating plugins out there that do the same.
>
> So using this approach, FormState will *always* think that the
> template class is HTML::Template.
>
>
I am happy to set that parameter in CAP::TT if you like. It makes sense for
there to be a way for plugins to know what templating system is being used.
It does bring up another question though. What do I set it to? It is not a
method that CAP::TT would call itself, so I guess just setting to to
'Template::Toolkit' would make the most sense.
Cheers,
Cees
##### CGI::Application community mailing list ################
## ##
## To unsubscribe, or change your message delivery options, ##
## visit: http://lists.openlib.org/mailman/listinfo/cgiapp ##
## ##
## Web archive: http://lists.openlib.org/pipermail/cgiapp/ ##
## Wiki: http://cgiapp.erlbaum.net/ ##
## ##
################################################################
More information about the cgiapp
mailing list