Hi.

I have the following task:
I parse the template before template toolkit, find all USE statements, create 
corresponding plugins ( call some methods that must be called before 
process()ing template ) and keep them in my plugin registry. I think that more 
suitable name is 'component' than plugin. When I process() template I would 
like that USE directive do nothing, and then I'd like to call render() method 
of loaded plugin that returns actual content... Now it's done like this:
- all plugins are simple perl modules not derived from Template::Plugin;
- all plugins have new() method: sub new {1};
- all plugins have my_new() method which I call before processing template
- each plugin know it's template (to parse USE statements)
- when my_new() called, plugin parse it's template, find USE statements, call 
my_new on corresponding "sub"plugins and store them in my component registry.
- when the render() called, plugin process it's template (and pass the 
reference to ComponentRegistry object, which store all created plugins)

Example Registration.tt:
...
[% USE l = Login %]
...
[% COMP_REGISTRY.get_component('Login', 'l').render(COMP_REGISTRY) %]
...

But I feel it's a WRONG way... I'd like to write:
[% USE l=Login %]
[% l.render %]


Can anybody suggest right way?

Thanks.
-- 
WBR dyker
Agava Software

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

Reply via email to