According to
http://www.template-toolkit.org/docs/plain/Manual/Config.html, using
custom components with TT is achieved like this:
Template->new( STASH => My::Stash->new() );
That seems to work ok for any of SERVICE, CONTEXT, STASH, GRAMMAR and
PARSER, provided only one is used at a time.
I've had trouble working out how you go about setting more than one of
those at a time, however. For example, say I want a custom CONTEXT and a
custom STASH too, I thought I would have to do the following:
Template->new(
CONTEXT => My::Context->new(),
STASH => My::Stash->new()
);
That doesn't seem to work though. Dumping the Template object reveals
that the custom context is used, but not the custom stash.
I've managed to get it working by nesting stuff like this:
Template->new(
SERVICE => My::Service->new(
CONTEXT => My::Context->new(
STASH => My::Stash->new()
)
)
);
If it does need to be done that way, what is the correct object
hierarchy? As far as I can see, starting from the top it should be
SERVICE -> CONTEXT -> STASH, but I'm not really sure where PARSER and
GRAMMAR fit into that.
I think it would be much more convenient if you could just do what the
docs imply, letting TT figure out where everything goes:
Template->new(
SERVICE => My::Service->new(),
CONTEXT => My::Context->new(),
STASH => My::Stash->new()
);
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates