I'm working on a template-reading module

Are you sure you need to do that ?

I've looked at various templating modules on CPAN. The reason I'm writing my own is because the templating modules I've seen on CPAN are either too robust (undue increase in loading time), or don't have the features I want, or both. I'm also writing it to try my hand at coding things I haven't done before, or in ways I haven't done before.

Okay, in that case you probably know what you are doing.


I just wanted to make sure you are aware of the CPAN option.
Surprisingly, a lot of people still do not make use of it.

The only situation where HTML::Template might be a
little inconvenient
is when you do not know the names of the parameters
(the references to
your data) beforehand.
Do you?

All the data to be interpolates is returned from a subroutine: &get('value') and the like. This is one of the reasons HTML::Template won't work well. If I recall correctly, there isn't a good way to do that with HTML::Template.

Yes, that is is unfortunately one of the weak spots of HTML::Template. I have to agree that there is no good way to do it.

When I was in a similar situation, I wrote a sub that introspects the HTML::Template instance to figure out the names of the parameters that are used in the template, then calls &get('value') for each of those and stuffs the result back into the template.
I guess that could work in your case, too.


HTML::Template does have an "associate" mechanism.
For every parameter that is undefined in the template the parameter is taken from the associate object.
To make this work, however, you need to provide an enumeration of all parameter names that are available.
If you can do this, the associate mechanism would work for you as well.



Cheers,


Thilo



Reply via email to