* Chris Winters <chris.winters at gmail.com> [2004/10/05 12:43]:
> On Tue, 5 Oct 2004 17:26:22 +0100, Dan Thomas <[EMAIL PROTECTED]> wrote:
> > Ideally I'd like to be able to disable the INCLUDE directive and
> > supply my own alternative (which can be accessible as a passed sub
> > rather than a proper directive).
> 
> It would probably be much easier to create your own Template::Provider
> subclass and make INCLUDE do your bidding. My brain is fuzzy but I
> think someone did this in the last few months on the list -- maybe a
> discussion of getting templates out of a database?

Template::Context.  Just subclass Template::Context and implement your
own include method.  This has the advatange of changing the meaning of
the INCLUDE directive, while not altering the grammar at all, so your
users could still do:

  [% INCLUDE kitchin/sink %]

And it would call your custom include method.

Use your new Template::Context subclass by doing this at the top of your
app:

  use Template::Config;
  $Template::Config::CONTEXT = 'My::Template::Context';

And then, whenever one of the TT modules needs a context object, it will
get your subclass.

Currently, INCLUDE is implemented on top of PROCESS.  You didn't
mention PROCESS, but if you also want to change how PROCESS works (the
internals are almost identical to INCLUDE), you should replace
Template::Context::process instead of Template::Context::include (the
latter is implemented in terms of the former).

(darren)

-- 
Remember, any design flaw you're sufficiently snide about becomes a
feature.
    -- Dan Sugalski

Attachment: pgpmnX7in8wF3.pgp
Description: PGP signature

Reply via email to