Re: [Templates] Limiting TT2's features
[prev]
[thread]
[next]
[Date index for 2004/10/05]
--wZdghQXYJzyo6AGC
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
* Chris Winters <chris.winters at gmail.com> [2004/10/05 12:43]:
> On Tue, 5 Oct 2004 17:26:22 +0100, Dan Thomas <godders@xxxxx.xxx> 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).
>=20
> 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 =3D '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)
--=20
Remember, any design flaw you're sufficiently snide about becomes a
feature.
-- Dan Sugalski
--wZdghQXYJzyo6AGC
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
iD8DBQFBYtHCzsinjrVhZaoRAvW5AJ9EYAjoq+M4ZAlBEgZ+JkQZyFXHogCfb5sc
4Qz8dxwel92rAocvqDiLDos=
=fWBm
-----END PGP SIGNATURE-----
--wZdghQXYJzyo6AGC--
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates