So I have objects that represent each my database objects. I want to hand the
object to HTML::Template directly as the param hash for the template. There
would be two things I can think of that would make this work beautifully.
a) If param() were change to instead of looping through all of the keys of the
argument to instead loop through all of the required template parameters
and check for them in the hash. This would allow me to implement a FETCH
method that does the necessary logic and database work to fetch just the
pieces that are actually needed in the template. This means the object
wouldn't have to know in advance everything that the template needs and
prepare all of it.
b) If param() were to accept an object for TMPL_LOOPs. It could call the
iterator operator <$object> to retrieve the parameters for each element of
the loop. This means I wouldn't have to fetch all of the elements at the
start and put them in a prebuilt array, This would allow more general
iterators to be used instead of just arrays.
so it should be possible to do
my $header = new databaseobject(...);
my $details = $header->iterate_details();
$mytemplate->param($header);
$mytemplate->param(details => $details);
and if the template had TMPL_VARs VAR1 and VAR2 it woudl access $obj->{VAR1}
and $obj->{VAR2} and not access anything else.
and to generate the array it would access <$details> until it returned undef
and not need random access.
--
Gregory Stark
Ideas And Associates
T +1 514 940 2891 x111
H +1 514 486 9705
C +1 514 945 3796
F +1 209 828 3730
http://www.ideasandassociates.com
[EMAIL PROTECTED]
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]