Re: [Templates] Patch to implement USE_SINGLETON idea in CAP::TT
[prev]
[thread]
[next]
[Date index for 2005/01/28]
On Fri, 28 Jan 2005 09:30:55 -0500, Michael Peters
<mpeters@xxxxxxxxx.xxx> wrote:
> Would there be any way to use this plugin and have multiple TT objects?
> I ask this because I have a situation where I have 2 TT objects that
> have very different parameters. For instance, one has the WRAPPER
> parameter set to a site wrapping template and the other doesn't.
>
> So at certain situations I have to use the first (showing a page) and in
> others I have to use the second (sending an email). So, is this possible
> with your plugin? If not, would it be hard to include (not having looked
> at the source yet)? Or is this a situation where I'm just better off not
> using the plugin.
You should be able to get it to work, although I am not sure how clean
it will look in your code.
package TT1;
use CGI::Application::Plugin::TT;
TT1->tt_config( ... );
package TT2;
use CGI::Application::Plugin::TT;
TT2->tt_config( ... );
package My::CGIApp;
use TT1;
use TT2;
sub my_runmode {
my $self = shift;
my $tt1 = TT1->tt_obj;
my $tt2 = TT2->tt_obj;
return $tt1->tt_process('template.tmpl', { param1 => 'value1' } );
# or just this
return TT1->tt_process('template.tmpl', { param1 => 'value1' } );
}
I think it looks pretty ugly myself, and would question why you need
two Template Toolkit objects in the same application. But I think
something along those lines should work...
Cheers,
--
Cees Hek
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates