On Thu, 27 Jan 2005 23:02:23 -0500, Perrin Harkins <[EMAIL PROTECTED]> wrote:
> On Thu, 2005-01-27 at 22:52 -0500, Cees Hek wrote:
> > Instead of configuring the object by
> > calling $self->tt_config(...) you can now provide all the options when
> > you 'use' the module.
> >
> > package My::App;
> >
> > use base qw(CGI::Application);
> > use CGI::Application::Plugin::TT (
> >               TEMPLATE_OPTIONS => {
> >                         POST_CHOMP   => 1,
> >                         FILTERS => {
> >                                      'currency' => sub { sprintf('$
> > %0.2f', @_) },
> >                         },
> >               },
> > );
> 
> As a general rule, I don't like it when modules co-opt import() for
> something that is totally different from importing.  I'd rather see this
> done in a separate method, at least as an option.

I can make the following work just as easily (in fact, that is what is
happening under the hood right now as tt_config is called from the
call to import)..

package My::App;

use CGI::Application::Plugin::TT;

My::App->tt_config(
              TEMPLATE_OPTIONS => {
                        POST_CHOMP   => 1,
                        FILTERS => {
                          'currency' => sub { sprintf('$%0.2f', @_) },
                        },
              },
);

That way tt_config can work as a class method for configuring a
persistent object, or as an object method to configure a one time
object.

> > I've also added a method to change the INCLUDE_PATH dynamically.called
> > tt_include_path (as per Perrin's suggestion).
> 
> Thanks!  Hopefully that will help make more people aware that this is
> allowed with TT, and they can realize some serious performance gains.

Well, I've started using it myself now, although I haven't done any
benchmarking to see what the gains actually are.

Cheers,

-- 
Cees Hek

_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to