but dont you have to build up the entire data structure before passing it to HTML::Template? I mean, you can't pass an HTML::Template template a DBI statement handle and call fetchrow within the template can you?
Perhaps the add-on expr module allows this? A cursory glance through the docs didn't show any such capability.
| [reply] |
package My::Associated::DBH::Wrapper;
# Called as:
# my $thingy = My::Associated::DBH::Wrapper->new(
# sth => $sth,
# param_name => 'Foo',
# );
sub new {
my $class = shift;
my %args = @_;
bless \%args, $class;
}
sub param {
my $self = shift;
my ($param) = @_;
return unless $param eq $self->{param_name};
my @values = $self->{sth}->fetchrow_array;
return unless @values;
return $values[0];
}
Then, when you build your template, you can go ahead and do this:
my $template = HTML::Template->new(
filename => 'my_template.tmpl',
associate => [ $thingy, $query ],
);
| [reply] [d/l] [select] |