[Templates] Modifying TT functions at run time
Simon Wilcox
essuu@ourshack.com
04 Nov 2002 16:02:18 +0000
On Mon, 2002-11-04 at 15:01, darren chamberlain wrote:
> * Simon Wilcox <essuu@ourshack.com> [2002-11-04 09:38]:
> > Is it possible to add a function like this at runtime or should I just
> > bite the bullet and write a plugin ?
>
> Nothing springs to mind that would help you -- a user can't load
> arbitrary Perl modules into a Template unless USE_PERL is set in the
> Template constructor (security feature). I think a plugin is your best
> plan:
I had been using a [% PERL %] block to add scalar_ops and I was hoping
to do the same sort of thing to attach the imgsize function so users
could use it as [% imgsize(imgfile) %] rather than [% imgfile.imgsize %]
which doesn't seem like much of a difference until imgfile is plain
string. I also have a conceptual issue with a vmethod that doesn't apply
to all scalars but that's probably just me.
Thanks for your plugin code. I think that is the way to go.
Many thanks,
Simon.